Javascript 角度指令单元测试-范围值未显示在编译结果中
这应该是由我这边的一些愚蠢的东西造成的,或者可能是使用旧版本的角度工具 “角度”:“1.2.12”, “角度路线”:“~1.2.7”, “角度加载器”:“1.2.x”, “角度模拟”:“1.2.12” 因此,我希望在某个时候看到范围VAL插入到编译指令中,但事实并非如此。 单元测试Javascript 角度指令单元测试-范围值未显示在编译结果中,javascript,angularjs,Javascript,Angularjs,这应该是由我这边的一些愚蠢的东西造成的,或者可能是使用旧版本的角度工具 “角度”:“1.2.12”, “角度路线”:“~1.2.7”, “角度加载器”:“1.2.x”, “角度模拟”:“1.2.12” 因此,我希望在某个时候看到范围VAL插入到编译指令中,但事实并非如此。 单元测试 var expect = chai.expect; var assert = chai.assert; beforeEach(module('myapp')); beforeEach(module('mytempla
var expect = chai.expect;
var assert = chai.assert;
beforeEach(module('myapp'));
beforeEach(module('mytemplates'));
describe('Testing notifications directive', function() {
var scope, elem;
var html = '<notifications></notifications>';
beforeEach(function(){
inject(function($compile, $rootScope, _tableService_) {
console.log('beforeEach')
scope = $rootScope.$new();
scope.testing = "i'm testing";
scope.inner = {testing: "i'm inner testing"};
element = $compile(html)(scope);
console.log('Pre digest['+element+']');
scope.$digest();
});
});
it('should render a notifications element', function() {
console.log('In unit test['+element+']');
});
原始部分
只是测试:{{testing}}Inner.testing你在吗?{{Inner.test}
输出
之前
预摘要[]
在单元测试中[Just testing:Inner.testing:你在吗?:]你也可以发布指令吗
var notificationsControllerName = 'NotificationController';
function notificationsController($rootScope, $scope, $interval, tableService) {
$scope.tableService = new tableService();
function reloadTables(){
$scope.tableService.load(function(data) {
$scope.problems = _.filter(data.tables, function(t) {return t.exception;});
_.each($scope.problems, function(notification){
notification.elapsed = (Date.now() - new Date(Date.parse(notification.created))).valueOf() / 1000 / 60;
});
});
}
// when this directive is on display, the controller will poll
$scope.cancelPoll = $interval(reloadTables, 15000);
// when a user logs out, the directive is destroyed and the poll will stop
$scope.$on('$destroy', function () {
$interval.cancel($scope.cancelPoll);
});
}
myApp.directive('notifications', function() {
return {
controller: notificationsController,
restrict: 'E',
replace: true,
templateUrl: 'partials/notifications.html',
};
});
myApp.controller(notificationsControllerName, notificationsController);