I'm trying to upgrade an AngularJS template we're using to its latest version.
Now, this template upgraded to AngularJS 1.6.9.
But now, after i've upgraded, i'm experiencing a problem that the vm from the parent controller is recognized in the directive's function, only after it exits. This is something that worked before the upgrade and suddenly stoppped working. Here's a sample code for a directive (this problem repeats itself now in all our directives):
(function () {
'use strict';
angular
.module('app.students')
.directive("studentOverview", StudentOverview);
function StudentOverviewController(generalSrv, $mdDialog, $q, utilSrv, exportSrv) {
var vm = this;
var someField = vm.student.someField; // vm.student is not recognized now, only after exiting the function... used to work before upgrade
}
function StudentOverview() {
return {
restrict: "AE",
templateUrl:
"app/main/students/views/studentDetails/tabs/studentOverview/studentOverview.html",
controller: StudentOverviewController,
controllerAs: "vm",
scope: {
student: "="
},
bindToController: true
};
}
})();
What am I doing wrong? This code worked perfectly before.