-
-
Save lucasdu4rte/ca6591ac8ca11c2f846ba6483cc94ee1 to your computer and use it in GitHub Desktop.
Angular: after-render (source: https://jsfiddle.net/loduarte/h53okjtu/220/)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div ng-app="myApp" ng-controller="MyCtrl"> | |
<div after-render="missionCompled">element</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var myApp = angular.module('myApp',[]); | |
myApp.directive('afterRender', ['$timeout', function ($timeout) { | |
var def = { | |
restrict: 'A', | |
terminal: true, | |
transclude: false, | |
link: function (scope, element, attrs) { | |
$timeout(scope.$eval(attrs.afterRender), 0); //Calling a scoped method | |
} | |
}; | |
return def; | |
}]); | |
myApp.controller('MyCtrl', function ($scope) { | |
$scope.missionCompled = function() | |
{ | |
console.log('Done'); | |
}; | |
}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment