Last active
August 29, 2015 14:25
-
-
Save misterzik/2a43304a09e424fc7c19 to your computer and use it in GitHub Desktop.
Revisions
-
misterzik revised this gist
Jul 24, 2015 . 1 changed file with 1 addition and 1 deletion.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 @@ -76,7 +76,7 @@ todoApp.controller('FeederController', </tr> <tr ng-repeat="event in events | orderBy: 'name'"> <td> {{event.name}} </td> -
misterzik revised this gist
Jul 24, 2015 . 1 changed file with 46 additions and 1 deletion.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 @@ -50,4 +50,49 @@ todoApp.controller('FeederController', "phone": "201-555-6666", "ext": "123", "departs": "Automation" } ================================================================= This is my .html File : ================================================================= <table class="table table-striped"> <tr> <td> Name </td> <td> Phone # </td> <td> Ext # </td> <td> Department </td> </tr> <tr> <td> {{event.name}} </td> <td> {{event.phone}} </td> <td> {{event.ext}} </td> <td> {{event.departs}} </td> </tr> </table> -
misterzik created this gist
Jul 24, 2015 .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,53 @@ ================================================================= This is a directive saved in a different folder: ================================================================= 'use strict'; todoApp.factory('eventData', function($http, $q){ return { getEvent: function(id){ var deferred = $q.defer(); // I added the extension '.json' after ID to only pick json. $http({method: 'GET', url: '/data/phonebook/'+id+'.json'}). success(function (data, status, headers, config){ deferred.resolve(data); }). error(function (data, status, headers, config){ deferred.reject(status); }); return deferred.promise; } }; }); ================================================================= This is a controller saved in a different section: ================================================================= 'user strict'; todoApp.controller('FeederController', function FeederController($scope, eventData) { $scope.events =[ ]; for (var i=1; i<2; i++){ eventData.getEvent(i).then( function (event){$scope.events.push(event);}, function (statusCode) {console.log(statusCode)}); } } ); ================================================================= This is my json File located on /data/phonebook/1.json : ================================================================= {"name": "John Foo", "id": 1, "phone": "201-555-6666", "ext": "123", "departs": "Automation" }