-
-
Save poonkave/0d831ea526f9b9b97cc0 to your computer and use it in GitHub Desktop.
This file contains 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 contactsApp = angular.module('contacts', ['ngRoute']); | |
contactsApp.config(['$routeProvider', | |
function($routeProvider) { | |
$routeProvider. | |
when('/detail/:id', { | |
templateUrl: 'templates/detail.html', | |
controller: 'DetailsController' | |
}) | |
} | |
]); | |
contactsApp.controller('ContactSearch', function($scope, $http) { | |
$scope.contacts = []; | |
$scope.searchFor = ""; | |
$scope.search = function() { | |
var searchFor = $scope.searchFor; | |
$http.get('../search.php?searchfor=' + encodeURI(searchFor)). | |
success(function(data, status, headers, config) { | |
$scope.contacts = data.contacts; | |
}). | |
error(function(data, status, headers, config) { | |
// log error | |
$scope.contacts = []; | |
}); | |
} | |
}); | |
contactsApp.controller('DetailsController', function($scope, $http, $routeParams) { | |
var id = $routeParams.id; | |
$http.get('../detail.php?id=' + id). | |
success(function(data, status, headers, config) { | |
$scope.contact = data.contact[0]; | |
}). | |
error(function(data, status, headers, config) { | |
// log error | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment