Angular controlleras syntax

Beschreibung

A-Level Angular Notiz am Angular controlleras syntax, erstellt von James Drummond am 18/12/2015.
James Drummond
Notiz von James Drummond, aktualisiert more than 1 year ago
James Drummond
Erstellt von James Drummond vor mehr als 8 Jahre
2
0

Zusammenfassung der Ressource

Seite 1

The syntax InvoiceController as invoice tells Angular to instantiate the controller and save it in the variable invoice in the current scope.What this means is that you can treat the controller as an object:myApp.controller()You need to be very careful about context: this is what you need to do to use $scope.$watch with this syntax: note binding of thisapp.controller('MainCtrl', function ($scope) { this.title = 'Some title'; // boom $scope.$watch(angular.bind(this, function () { return this.title; // `this` IS the `this` above!! }), function (newVal, oldVal) { // now we will pickup changes to newVal and oldVal }); });

Zusammenfassung anzeigen Zusammenfassung ausblenden

ähnlicher Inhalt

Angular Nuts and Bolts
James Drummond
Angular application scaffolding
James Drummond
Angular-hint
James Drummond
ng-model-options
James Drummond
Architecture and general layout
James Drummond
Quiz - Object Oriented Javascript
arunram.krish
Examen Fundamentos Basicos de Programación
Jose Valderrama0721
Test I. Introduction to web technologies
Angel Martínez Rodriguez
Angular
Kingsley Bawuah
The Princeton Review Chapter 9 Rotational Motion
Anibal Santamaria
JavaScript Fundamentals
Andrew Watters