mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-16 23:30:23 +00:00
docs(tutorial/step08): use DI annotations
This commit is contained in:
parent
01cbe2f398
commit
a61d7999a4
1 changed files with 8 additions and 6 deletions
|
|
@ -61,12 +61,14 @@ the same way as the phone list controller.
|
|||
|
||||
__`app/js/controllers.js`:__
|
||||
<pre>
|
||||
var phonecatApp = angular.module('phonecatApp',[]);
|
||||
phonecatApp.controller('PhoneDetailCtrl', ['$scope', '$routeParams', '$http', function($scope, $routeParams, $http) {
|
||||
$http.get('phones/' + $routeParams.phoneId + '.json').success(function(data) {
|
||||
$scope.phone = data;
|
||||
});
|
||||
}]);
|
||||
var phonecatControllers = angular.module('phonecatControllers',[]);
|
||||
|
||||
phonecatControllers.controller('PhoneDetailCtrl', ['$scope', '$routeParams', '$http',
|
||||
function($scope, $routeParams, $http) {
|
||||
$http.get('phones/' + $routeParams.phoneId + '.json').success(function(data) {
|
||||
$scope.phone = data;
|
||||
});
|
||||
}]);
|
||||
</pre>
|
||||
|
||||
To construct the URL for the HTTP request, we use `$routeParams.phoneId` extracted from the current
|
||||
|
|
|
|||
Loading…
Reference in a new issue