我需要将测试应用于特定的控制器.
测试这个控制器是好的:
angular.module('app', []).controller('PasswordController', function PasswordController($scope) {
$scope.password = '';
$scope.grade = function () {
var size = $scope.password.length;
if (size > 8) {
$scope.strength = 'strong';
} else if (size > 3) {
$scope.strength = 'medium';
} else {
$scope.strength = 'weak';
}
};
});
Run Code Online (Sandbox Code Playgroud)
但我想测试一下:
angular.module('app', []).controller('PasswordController', function PasswordController($scope) {
var vm = this;
vm.password = '';
function grade() {
var size = vm.password.length;
if (size > 8) {
vm.strength = 'strong';
} else if (size > 3) …Run Code Online (Sandbox Code Playgroud) 我正在使用Angulartics从AngularJS跟踪Google Analytics的一些信息.
我需要设置自定义维度,我需要做这样的事情,但使用Angulartics第三方.
ga('set', 'dimension5', 'custom data');
Run Code Online (Sandbox Code Playgroud)
在我刚刚看到的Angulartics 文档pageTrack()或eventTrack()方法中.如果可能的话,我不这样做?