Angularjs单元测试指令与controlleras

时间:2016-09-29 11:24:30

标签: angularjs

我很困惑如何使用controllerAs对我的自定义指令进行单元测试。这是代码 -

var SomeDirective = function () {
return {
    restrict: 'E',
    scope: {
        model: '='           
    },
    template:  (__dirname + '/Some.html', 'utf8'),
    link: link,
    controller: "SomeController",
    controllerAs: 'some',
    bindToController: true,
};
  function link (scope, element, attrs) {
    if (_.isUndefined(scope.some.model)) {
        throw new Error('The directive requires a "model" ');
    }
}

控制器 -

var  SomeController = (function () {
var SomeController = function SomeController (
    someService
   ) {

  };
SomeController.prototype.dosomething = function ( ) {
           //do something
}    

SomeController.prototype.dosomething2 = function ( ) {       
       //do something2
};

你能告诉我吗?

0 个答案:

没有答案
相关问题