In angular you can either write `directive('myDirective', ['$http', function($http) {...}])`, which is minification safe, but it's also possible to write `directive('myDirective', function($http) {...})` which might not be minification safe, but valid angular nonetheless.
Rename name property from ng.IDirective as there is no mention of this property in the official API documentation (https://docs.angularjs.org/api/ng/service/$compile) and it was causing issues with directives made as classes like so:
class MyDirective implements ng.IDirective {
public template = "<div>{{ test }}</div>";
public scope = {
test: "="
};
public static name = "myDirective";
public static $inject: string[] = ["$http"];
constructor(private $http: ng.IHttpService) {
}
public link(scope: IDirectiveScope, element: ng.IAugmentedJQuery, attrs: ng.IAttributes) {
}
}
angular.module("app")
.directive(MyDirective.name, DirectiveFactory.getFactoryFor(UserProjectRoles));
See http://stackoverflow.com/questions/38853868/typeerror-when-class-has-static-member-name for more details.
Changing it to another non-reserved name fixes the issue.
Typescript 2.0 starts checking the compatibility of the index
signature with the base JQuery interface; Hence we are forced to
return Document & HTMLElement to be compatible with the base.
JQ(lite)-unwrapping $document[0] should be of type Document instead of
the default HTMLElement. Otherwise important methods like
getElementById are missing.
Angular 1.5+ component Controllers have four new lifecycle hooks:
$onInit()
$onDestroy()
$onChanges(...)
$postInit()
There is currently no reference to any of then in the definitions files.
I added an additional interface to the component's controller type that defines the new hooks with the official documentation from docs.angularjs.org
* Add ControllerService to angular-mocks
The definition in angular.d.ts changed that used to included this definition.
Needed because of 69d2fb9
* Added unit tests for controller service mock
I recently came up with this solution so I could leverage my custom scope when grabbing the scope from a controller using angular.element. It works well and with the <T extends IScope> it ensures that you can only set it to an interface that extends IScope.