Angularjs (1.4.X) Cheat Sheet

Angularjs (1.4.X) Cheat Sheet

TypeScript (1.4) AngularJS (1.4.x) Cheat Sheet Angular TypeScript Definitions: Controllers https://github.com/borisyankov/DefinitelyTyped/tree/master/angularjs $controller ng.IControllerService Resources: Form Controller ng.IFormController Types https://github.com/borisyankov/DefinitelyTyped Model Controller ng.INgModelController TypeScript http://www.typescriptlang.org/ $rootScope ng.IRootScopeService Angular CDN https://code.angularjs.org/ Browser Example: Define a Controller Window ng.IWindowService Browser ng.IBrowserService // undocumented // <reference path="../../typings/angularjs/angular.d.ts"/> module MyModule { Document ng.IDocumentService "use strict"; $timeout ng.ITimeoutService $interval ng.IIntervalService var app = getModule(); $location ng.ILocationService class MainController { Modules private isAlive: boolean = false; private lastCheck: Date = new Date(); Angular global object ng.IAngularStatic Provider ng.IServiceProvider constructor(private $interval: ng.IIntervalService) { Module ng.IModule var intervalFn = () => { this.isAlive = result; this.lastCheck = new Date(); Example: Define a Module }; $interval(intervalFn, 1000); // <reference path="../typings/angularjs/angular.d.ts"/> intervalFn(); module MyModule { } "use strict"; angular.module("myModule", ["ngRoute"]); public static $inject: string[] = ["$interval"]; } export var getModule: () => ng.IModule = () => { return angular.module("myModule"); app.controller("mainCtrl", MainController); } } } 1430 West Peachtree Street, Suite 425 Atlanta, Georgia 30309 678.999.3002 iVision.com TypeScript (1.4) AngularJS (1.4.x) Cheat Sheet Directives Routes (angular-route.d.ts) Directive Factory ng.IDirectiveFactory Route Service ng.route.IRouteService Directive ng.IDirective Route ng.route.IRoute Route Parameters ng.route.IRouteParamsService Example: Define a Directive (using a factory) Example: Define a Route class MyDirective implements ng.IDirective { public restrict: string = "A"; app.config([ public require: string = "ngModel"; "$routeProvider", ($routeProvider: angular.route.IRouteProvider) => { public scope = { $routeProvider.when("/My/View/:id", { state: '=' templateUrl: "/My/View", }; controller: "myViewCtrl", controllerAs: "ctrl" constructor(private $location: ng.ILocationService) { }); } } ]); public link: ng.IDirectiveLinkFn = (scope: ng.IScope, element: ng.IAugmentedJQuery, attrs: ng.IAttributes, ngModel: any) => { // do stuff here } Filters } $filter ng.IFilterService var app = getModule(); Custom Filter ng.IFilterProvider app.directive("myDirective", ["$location", ($location: ng.ILocationService) => new MyDirective($location)]); Misc. Logging ng.ILogService Exception Handling ng.IExceptionHandlerService Promise Service ng.IQService Promise ng.IPromise<T> $http ng.IHttpService Injector ng.auto.IInjectorService $provide ng.auto.IProvideService 1430 West Peachtree Street, Suite 425 Atlanta, Georgia 30309 678.999.3002 iVision.com.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    2 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us