What does “require” of directive definition object take?

The require parameter, including its prefixes, is documented on the $compile API reference page. Require another directive and inject its controller as the fourth argument to the linking function. The require takes a string name (or array of strings) of the directive(s) to pass in. If an array is used, the injected argument will be … Read more

AngularJS : ng-repeat filter when value is greater than

Create a predicate function on the relevant scope: $scope.greaterThan = function(prop, val){ return function(item){ return item[prop] > val; } } As a first argument, it takes a property name on the object. The second argument is an integer value. Use it in your view like this: <tr ng-repeat-start=”list in Data.Items | filter: greaterThan(‘NumberOfStamps’, 0)”> Demo

Custom child directive accessing scope of parent

The city directive $parent is a transcluded scope of state directive. The transcluded scope of the state directive is inherit for $parent of state directive which is controller thus that is why $parent.MyName = India. The $parent of transcluded scope is the state directive isolated scope ( scope = {} ) that is why $parent.$parent.MyName … Read more

ng-click doesn’t work within the template of a directive

You’ve got a scope issue. Since you used isolated scope in your directive with scope: { value: ‘=’ }, it no longer has access to your controller’s scope that has editQuestion. You need to pass editQuestion along to your directive’s scope so it knows how to call it. This is typically pretty easy, but because … Read more

AngularJS directive $destroy

The i18n example you provided would work if you only ever used it once. I don’t think you should be doing the event binding inside the compile function. You can do it inside the link function instead: angular.directive(‘i18n’, [‘$rootScope’, ‘LocaleService’, function($rootScope, LocaleService) { return { restrict: ‘EAC’, link: function(scope, element, attrs) { var cleanup; var … Read more

AngularJS UI Bootstrap Tabs that support routing

To add routing you typically use an ng-view directive. I’m not sure it’s easy enough to modify angular UI to support what you’re looking for, but here’s a plunker showing roughly what i think you’re looking for (it’s not necessarily the best way of doing it – hopefully someone can give you a better solution … Read more

Callback function inside directive attr defined in different attr

So what seems like the best way is using the isolated scope as suggested by ProLoser app.directive(‘mySave’, function($http) { return { scope: { callback: ‘&mySaveCallback’ } link: function(scope, element, attrs) { element.on(“click”, function() { $http.post(‘/save’, scope.$parent.data).success(returnedData) { // callback defined on my utils service here scope.callback(); // fires alert } }); } } }); For … Read more

Check existence of attribute in AngularJs Directive

The way to do this is to check for the existence of the attributes within the link function’s attrs parameter, and assign this to variables within your directive’s isolate scope. scope:{}, link: function(scope, element, attrs){ scope.status=”status” in attrs; }, This should work without having to use an if statement within your link function.