Skip to content

Instantly share code, notes, and snippets.

@misterzik
Last active August 29, 2015 14:25
Show Gist options
  • Select an option

  • Save misterzik/2a43304a09e424fc7c19 to your computer and use it in GitHub Desktop.

Select an option

Save misterzik/2a43304a09e424fc7c19 to your computer and use it in GitHub Desktop.

Revisions

  1. misterzik revised this gist Jul 24, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -76,7 +76,7 @@ todoApp.controller('FeederController',

    </tr>

    <tr>
    <tr ng-repeat="event in events | orderBy: 'name'">
    <td>
    {{event.name}}
    </td>
  2. misterzik revised this gist Jul 24, 2015. 1 changed file with 46 additions and 1 deletion.
    47 changes: 46 additions & 1 deletion gistfile1.txt
    Original 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>
  3. misterzik created this gist Jul 24, 2015.
    53 changes: 53 additions & 0 deletions gistfile1.txt
    Original 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"
    }