You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 7, 2018. It is now read-only.
I don't get it here, the injection of $scope and instead taking and making use of $$scope which is an internal implementation which is not supposed to be expose. or is it a typo or there is a reason for it?
@directive('ngModuleName', 'atSomeDirective')
class SomeDirectiveController {
public static controllerAs: 'someDirectiveCtrl';
public static templateUrl: string = '/partials/some-directive.html';
public static link: angular.IDirectiveLinkFn = (scope, element, attrs, ctrl: SomeDirectiveController) => {
ctrl.init(attrs.atSomeDirective);
};
constructor(
@inject('$scope') private $$scope: angular.IScope,
@inject('$parse') private $$parse: angular.IParseService
) {
// do stuff with $$scope and $$parse;
}
public init(anArg: string): boolean {
// do some stuff with this.$$parse and this.$$scope
}
}
The text was updated successfully, but these errors were encountered:
And controller is assigned to $scope with controllerAs.
This situation will produce some errors (circular reference). If we try to add for example underscore in front of any injected dependency assigned to class instance (_scope or _$scope) we will still have this problem. Actually AngularJS ignores $ and $$ prefixed object members when rendering scope in view, so it has to be prefixed with $ or $$. So I decided to use simple idea - make every dependency injected to class private (so TS knows it should be not used externally) and be sure it's prefixed with $$ to omit all angular based problems.
I feel that it's not best idea, because there is a risk of name collision with some internal AngularJS, but I did not found better solution.
I don't get it here, the injection of$scope and instead taking and making use of $ $scope which is an internal implementation which is not supposed to be expose. or is it a typo or there is a reason for it?
@directive('ngModuleName', 'atSomeDirective')
class SomeDirectiveController {
}
The text was updated successfully, but these errors were encountered: