I\'m wondering what the use cases are for these two methods of creating a controller:
Using ngController:
myApp.controller(\'myContr
Adding some detail regarding accessing methods and values within the directive controller:
Parent directive
myApp.directive ( 'parent', [ function() {
return {
restrict: 'A',
scope: {},
controller: [ '$scope', function( $scope ) {
//this.myVar = ''; //accessible in child directives
//$scope.myVar = ''; //accessible in template
$scope.myVar = this.myVar = '';
}],
template: ' {{myVar}} ',
link: function( scope, element, attrs ) {
console.log( scope.myVar );
}
};
}]);
Child directive
myApp.directive ( 'child', [ function() {
return {
restrict: 'A',
require: '^parent',
link: function( scope, element, attrs, ctrl ) {
console.log( ctrl.myVar );
}
};
}]);