Angular
2 flashcards · Programming Languages · by lakesare
What's the second argument? phonecatApp.controller('PhoneListController', ...)
The controller is simply a constructor function that takes a $scope parameter: // Define the `phonecatApp` module var phonecatApp = angular.module('phonecatApp', []); // Define the `PhoneListController` controller on the `phonecatApp` module phonecatApp.controller('PhoneListController', function PhoneListController($scope) { $scope.phones = [ { name: 'Nexus S', snippet: 'Fast just got faster with Nexus S.' }, { name: 'Motorola XOOM™ with Wi-Fi', snippet: 'The Next, Next Generation tablet.' }, {…
What html does this angular expect: angular. module('myApp'). component('greetUser', { template: 'Hello, {{$ctrl.user}}!', controller: function GreetUserController() { this.user = 'world'; } });
<body> <!-- The following line is how to use the `greetUser` component above in your html doc. --> <greet-user></greet-user> </body> Now, every time we include <greet-user></greet-user> in our view, AngularJS will expand it into a DOM sub-tree constructed using the provided template and managed by an instance of the specified controller.