I am new to angular, and have to work with angularjs, also. The majority I can relate to angular, but there is the following code that has me a bit baffled, and any assistance is appreciated.
angular
.module('Test')
.directive('nbTest', [savedTest]);
/* @ngInject */
function savedTest() {
var directive = {
restrict: 'E',
scope: true,
templateUrl: 'test/newTest/directives/savedTest/nbSavedTests.tmpl.html',
controllerAs: 'vm',
controller: ['$scope', '$mdUtil', '$mdDialog', '$timeout', 'nbApplicationFactory', 'dateService', savedTestCtrl]
};
return directive;
What I am specifically confused about is the array for the 'controller'. What I am wanting to do is use the $onInit life cycle hook, but am baffled how to when the controller is defined how it is.
ngOnInityou mean$onInit?controllerarray is a list of named dependencies (strings), followed by the controller function itself (savedTestCtrl). docs.angularjs.org/guide/di#dependency-annotation