Guest User

Untitled

a guest
Jan 24th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. class HerosComponentController implements ng.IComponentController {
  2.  
  3. public heros: IHero[];
  4.  
  5. constructor() {}
  6.  
  7. public $onInit () {
  8. this.heros = HEROS;
  9. }
  10. }
  11.  
  12. class HerosComponent implements ng.IComponentOptions {
  13.  
  14. public controller: ng.Injectable<ng.IControllerConstructor>;
  15. public controllerAs: string;
  16. public template: string;
  17.  
  18. constructor() {
  19. this.controller = HerosComponentController;
  20. this.controllerAs = "$ctrl";
  21. this.template = `
  22. <ul>
  23. <li ng-repeat="hero in $ctrl.heros">{{ hero.name }}</li>
  24. </ul>
  25. `;
  26. }
  27. }
  28.  
  29. angular
  30. .module("mySuperAwesomeApp", [])
  31. .component("heros", new HerosComponent());
  32.  
  33. angular.element(document).ready(function() {
  34. angular.bootstrap(document, ["mySuperAwesomeApp"]);
  35. });
Add Comment
Please, Sign In to add comment