mardi 23 décembre 2014

Difference between directive controller and normal controller


What is the difference between a normal ng-controller and a controller inside a directive.



<div ng-controller="MyCtrl">
<directive></directive>
</div>


Below i have a directive inside MyCtrl and my directive also has a controller defined.



var app = angular.module('myApp',[]);

app.directive('map', function() {
return {
restrict: 'E',
controller: function(){}
}
});

function MyCtrl($scope) {}



  1. What is the difference between a normal ng-controller and a controller inside a directive.

  2. Why does the directive have a controller function?.





Aucun commentaire:

Enregistrer un commentaire