EDIT: Added $ routeProvider and $ routeParams, but $ routeParams.productId is always undefined. This was my initial attempt, but I thought it was the wrong way. In any case, this does not work at the moment.
I'm starting to learn AngularJS, and I have a very simple question: Depending on the identifier contained in the url, I would like to display another BD entry.
... <div ng-app=MyApp> <div ng-controller="MyCtrl"> {{ record }} </div> </div> ...
My Javascript File:
var MyApp = angular.module("MyApp",[]); MyApp.config(['$routeProvider', function($routeProvider) { $routeProvider .when('/get/:productId', { controller: 'MyCtrl' }); }]) MyApp.controller('MyCtrl',['$scope','$routeParams','$http', function($scope,$routeParams,$http) { $http.get("/get/"+$routeParams.productId).success(function(data) { $scope.record = data; }); }])
I tried using $ routeProvider and $ routeParams without success.
Thanks in advance, Bill
billdangerous
source share