The isolated scale was what I used to reuse a function that is defined differently by several controllers. According to the docs, when you highlight the scope of directives, for example:
scope: { myIsolatedFunc: '=' }
Angular will look for the current scope for the property named as the value of the element's myIsolatedFunc property. which means:
if you have a function called $scope.func1 and an element defined as:
<div myIsolatedFunc="func1">
and on a different route with a different controller, a function like $scope.func2 , along with an element defined as:
<div myIsolatedFunc="func2">
you can use both functions in the directive:
app.directive('thedirective', function () { return { scope: { myIsolatedFunc: '=' }, link: function (scope, $element, attrs) { $scope.myIsolatedFunc(attrs.thedirective); } } });
not to mention the need to have different names for different functions.
Reyraa
source share