Reputation: 7585
I was wondering about the difference between scope
and model
within a directive.
The following 2 directives behave exactly the same:
angular.module( 'exampleApp', [] )
.directive( 'exampleDirective1', function() {
return {
restrict: 'E',
scope: { // using scope here
info: '='
},
template: '<div><span>{{ info }}<span> <input ng-model="info"></div>'
};
} )
.directive( 'exampleDirective2', function() {
return {
restrict: 'E',
model: { // using model here
info: '='
},
template: '<div><span>{{ info }}<span> <input ng-model="info"></div>'
};
} );
Am I missing something?
Upvotes: 1
Views: 458