Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Angular #6

Angular #6

Danila Marchenkov

August 19, 2017
Tweet

More Decks by Danila Marchenkov

Other Decks in Programming

Transcript

  1. .config() Gets executed during the provider registrations and configuration phase.

    Only providers and constants can be injected into configuration blocks.
  2. .run() Gets executed after the injector is created and are

    used to kickstart the application. Only instances and constants can be injected into run blocks
  3. angular.module('myApp', []) .factory('willBreak', function($rootScope) { // $rootScope is implicitly injected

    }) .run(['willBreak', function(willBreak) { // AngularJS will throw when this runs }]); var MyController = function($scope, greeter) {} MyController.$inject = ['$scope', 'greeter']; someModule.controller('MyController', MyController); npm install -g ng-annotate
  4. API • CSS-animations • css class hooks • ng-enter •

    ng-leave • JS-animations • module.animation() api
  5. Animation JS api myModule.animation('.slide', [function() { return { enter: function(element,

    doneFn) { jQuery(element).slideIn(1000, doneFn); } } }]); .slide.ng-enter { transition:0.5s linear all; transform:translateY(-100px); } .slide.ng-enter.ng-enter-active { transform:translateY(0); } <div class="slide"> Slide in and out </div>
  6. $animateCss myModule.animation('.slide', ['$animateCss', function($animateCss) { return { enter: function(element) {

    return $animateCss(element, { event: 'enter', structural: true, addClass: 'maroon-setting', from: { height: 0 }, to: { height: 200 } }); } } }]);
  7. let User = $resource('/user/:userId', { userId: ’@id’ }); let user

    = User.get({ userId: 123 }, () => { user.abc = true; user.$save(); });
  8. { 'get': { method:’GET’ }, 'save': { method:’POST' }, 'query':

    { method:'GET', isArray:true}, 'remove': { method:’DELETE' }, 'delete': { method:’DELETE' } }; var app = angular.module('app', ['ngResource', 'ngRoute']); app.factory('Notes', ['$resource', function($resource) { return $resource('/notes/:id', null, { 'update': { method:'PUT' } }); }]); app.controller('NotesCtrl', ['$scope', '$routeParams', ‘Notes', function($scope, $routeParams, Notes) { var note = Notes.get({ id: $routeParams.id }); $id = note.id; }]);
  9. XSS