Created
November 28, 2017 02:30
-
-
Save tedhagos/6c2a8ebbf5d93bdada472d506130a8b8 to your computer and use it in GitHub Desktop.
Angular Directives Controllers Modules
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html ng-app="app"> | |
| <body ng-controller="ctrl"> | |
| <my-directive></my-directive> | |
| <author-card></author-card> | |
| <input type="text" ng-model="myinput"><br/> | |
| <button ng-click="clickMe(myinput)"> Click me</button> | |
| {{ greeting }} | |
| <script src="bower_components/angular/angular.js"></script> | |
| <script src="1.js"></script> | |
| </body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var mod = angular.module('app',[]); | |
| mod.directive('myDirective', function(){ | |
| return { | |
| restrict: 'AEC', | |
| template: "<h1>Hello Directive</h1>" | |
| }; | |
| }); | |
| mod.directive('authorCard', function() { | |
| return { | |
| restrict: 'E', | |
| templateUrl: 'author-card.html' | |
| } | |
| }); | |
| mod.controller('ctrl', function($scope){ | |
| $scope.clickMe = function(name) { | |
| $scope.greeting = "Hello " + name; | |
| } | |
| $scope.user = { | |
| lastname: "Gosling", | |
| firstname: "James" | |
| }; | |
| $scope.user2 = { | |
| lastname: "Hevery", | |
| firstname: "Misko" | |
| }; | |
| $scope.authors = [ | |
| {name: 'Victor Hugo', book: 'Les Miserables'}, | |
| {name: 'Bjarne Stroustrup', book: 'C++ Programming'}, | |
| {name: 'James Gosling', book: 'Java Programming'}, | |
| {name: 'Leo Tolstoy', book:'War and Peace'} | |
| ]; | |
| }); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment