I have a query regarding the scope usage in AngularJS and TypeScript.
I recently joined a project midway and am currently adjusting to using TypeScript. Previously, I had always written my AngularJS code directly in JavaScript.
What intrigues me about this project is the unconventional approach used in defining members to be bound in the controllers and views. Instead of assigning them to the $scope object passed into the constructor, they are directly placed on the Controller class itself, as demonstrated below:
module Wizard.Controllers {
"use strict";
export class LoginController extends BaseAppealController {
static $inject = ["$q", "$scope"];
private isInForgottenPasswordMode: boolean;
private passwordSent: boolean;
// other properties
private scope;
constructor($q: angular.IQService, $scope) {
super($q);
// other constructor-related activities
this.isInForgottenPasswordMode = false;
this.passwordSent = false;
}
// ..functions and views interact with isInForgottenPasswordMode
// and passwordSent as if they were on a $scope..
}
}
Upon inspecting the scope using an AngularJS Batarang tool in the view, I observed that the LoginController contains a scope with these two properties - inForgottenPasswordMode and passwordSent.
I would appreciate it if someone could clarify how this setup works. Is binding to the scope not necessary in this scenario? Have I overlooked something in the context of AngularJS?