What is the difference between scope and model within a directive definition in AngularJS

448 Views Asked by At

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?

0

There are 0 best solutions below