Created
November 14, 2014 10:16
-
-
Save Sennahoi/1612771372f13728f4ba to your computer and use it in GitHub Desktop.
Revisions
-
Sennahoi created this gist
Nov 14, 2014 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,6 @@ <ul class="list"> <li ng-repeat="location in locations"> <a href="#">{{location.id}}. {{location.name}}</a> </li> </ul> <map locations='locations'></map> 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ // scope.location = { id : 123 }; // Source: http://stackoverflow.com/questions/21667613 app.directive('map', function() { return { restrict: 'E', replace: true, template: '<div></div>', scope: { // creates a scope variable in your directive // called `locations` bound to whatever was passed // in via the `locations` attribute in the DOM locations: '=locations' }, link: function(scope, element, attrs) { scope.$watch('locations', function(locations) { angular.forEach(locations, function(location, key) { // do something }); }); } }; });