angularjs - Test access controller in angular directive -
i need test methods controller directive.
app.angular.directive('minicrud', function () { return { restrict: 'e', require:"ngmodel", scope: { minicrudheader: '@', minicrudconfig: '=', modelvalues : "=ngmodel" }, templateurl: 'templates/mini-crud.html', controller: ['$scope', 'lodash', 'filterfilter', function($scope, _, filterfilter){ $scope.vm = { getvalue: function(item, index) { var prop = $scope.minicrudconfig.fields[index].name; return item[prop]; } // other methods } } }] }; });
how can acess $scope.vm.getvalue()?
i hope know how test directive. since directive creates isolated scope have use isolatedscope
function on object returned angular.element.
once create html directive element in test, compile , link scope. can use compiled element hold of isolated scope
var s = angular.element(compiledandlinkeddom).isolatedscope(); s.vm.getvalue();
Comments
Post a Comment