小编Bon*_*Jon的帖子

如何设置新浏览器选项卡的标题?

我对该链接的新标签有疑问.

无论如何我可以在用户点击链接之前设置浏览器标签标题吗?如果新选项卡中包含的html没有title属性,似乎没有办法讨论新选项卡的标题.我对吗?如何设置标题?

//the href is dynamic so I can't set them one by one because I have 100+ html file here
<a href="test.html" target="_blank">open me<a>
Run Code Online (Sandbox Code Playgroud)

html javascript css

10
推荐指数
1
解决办法
3万
查看次数

如何获取angular.js中的复选框值

我一直在搜索这里的主题,但无法找到答案.

当用户在Angular中检查它时,我试图获取复选框的值.我有类似的东西

<div class="checkbox">

<div class="checkbox" ng-repeat="product in products">
    <input type="checkbox" ng-model="product"/> {{product.name}}
</div>

<button ng-click='add()'></button>
Run Code Online (Sandbox Code Playgroud)

我希望在我的js中有一些东西

$scope.add = function() {
    //I want to add the checked product in the selectedProduct array
    $scope.selectedProduct = ['product1', 'product2', 'product4']  => the selected products.
}
Run Code Online (Sandbox Code Playgroud)

我该怎么做呢?谢谢!

html javascript angularjs

4
推荐指数
1
解决办法
7313
查看次数

在我的例子中,如何解决'undefined不是一个函数'

我正在尝试为我的控制器创建单元测试.

我有类似的东西

angular.module('myApp').controller('testCtrl', ['$scope', 'testFactory',
    function($scope, testFactory) {
        //I am getting the error when I ran Karma
        //TypeError: 'undefined' is not a function (evaluating  
        //'$scope.$watch')
        $scope.$watch(function(){
            return testFactory.returnItem; // watch the factory returned data
        }, function(newVal){
            console.log('call here')
        });
    }
]}
Run Code Online (Sandbox Code Playgroud)

在我的工厂文件中

angular.module('myApp').factory('testFactory', ['Product','$cookies','$q',
    function(Product ,$cookies, $q) {
        var service = {};
        service.getProduct = function() {
            var deferred = $q.defer();
            var that = this;
            Product.query({
                Id: 123,
            }, function(product) {           
                that.returnItem = product;
                deferred.resolve(product);
            });
            return deferred.promise;
        };
        return service; …
Run Code Online (Sandbox Code Playgroud)

javascript unit-testing angularjs

4
推荐指数
1
解决办法
2152
查看次数

标签 统计

javascript ×3

angularjs ×2

html ×2

css ×1

unit-testing ×1