Skip to content

Instantly share code, notes, and snippets.

@mattmazzola
Last active April 12, 2016 06:18
Show Gist options
  • Save mattmazzola/dd19763cc01cae02595956443712c2bd to your computer and use it in GitHub Desktop.
Save mattmazzola/dd19763cc01cae02595956443712c2bd to your computer and use it in GitHub Desktop.
Angular 1.4x Component
class Controller {
$scope: ng.IScope;
$timeout: ng.ITimeoutService;
MyService: MyService;
static $inject = [
'$scope',
'$timeout',
'MyService'
]
constructor($scope: ng.IScope, $timeout: ng.ITimeoutService, MyService: MyService) {
this.$scope = $scope;
this.$timeout = $timeout;
this.MyService = MyService;
}
submitClicked(thing: Thing) {
return this.MyService.save(thing);
}
...
}
export default class Component {
restrict = 'E';
bindToController = true;
templateUrl = "/App/components/my-component/template.html";
controller = Controller;
controllerAs = 'vm';
scope = {
name: "="
}
link($scope: ng.IScope, element: ng.IAugmentedJQuery, $attrs, controller: Controller) {
...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment