Last active
August 29, 2015 14:07
-
-
Save xcarpentier/5b02f5c43e245fc7b3b8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 my-example max="77"></div> |
This file contains hidden or 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
function myExample() { | |
var directive = { | |
restrict: 'EA', | |
template: '<div>hello world</div> \ | |
<div>max={{exVm.max}} \ | |
<input ng-model="exVm.max"/> \ | |
</div> \ | |
<div>min={{exVm.min}} \ | |
<input ng-model="exVm.min"/> \ | |
</div> \ | |
', | |
scope: { | |
max: '=' | |
}, | |
link: linkFunc, | |
controller : DirCtrl, | |
controllerAs: 'exVm' | |
}; | |
return directive; | |
/* @ngInject */ | |
function DirCtrl($scope) { | |
//Injecter $scope pour la comparaison | |
/* jshint validthis:true */ | |
var exVm = this; | |
exVm.min = 3; | |
exVm.max = $scope.max; | |
console.log('CTRL: $scope.max = %i', $scope.max); | |
console.log('CTRL: exVm.min = %i', exVm.min); | |
console.log('CTRL: exVm.max = %i', exVm.max); | |
} | |
/* @ngInject */ | |
function linkFunc(scope, el, attr, ctrl) { | |
console.log('LINK: scope.max = %i', scope.max); | |
console.log('LINK: scope.exVm.min = %i', scope.exVm.min); | |
console.log('LINK: scope.exVm.max = %i', scope.exVm.max); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment