0
我是angularJs的新手。我正在創建一個應用程序,我在URL中傳遞用戶標識,然後嘗試使用Routeparam獲取Js文件中的標識,但它不工作。我正在使用MVC 4和angularjs。 請參閱我的代碼angularjs routePrams不工作
我的網址/首頁/ GetUserInformation?userID = 44。我想在下面的代碼中的用戶ID
var userInformationApp = angular.module('UserInformationApp', ['ngResource'])
.config(function config($routeProvider, $stateProvider)
{
$locationProvider.html5Mode(true).hashPrefix('!');
$routeProvider.
when('/Home/GetUserInformation?userID=:ID',
{
templateUrl: "UserInformation.cshtml",
controller: "UserInformationController"
})
angular.module('UserInformationApp', []).controller("UserInformationController", function ($scope, $routeParams, $http)
{
debugger;-----// My debugger is not hitting when I used routeParams.If I remove Route params Then it is working fine but route params then come undefined.
$scope.saveNote = function()
{
$scope.newNote = $scope.userNote;
$scope.intialValue = true;
$scope.record = $routeParams.ID;///// This I saw in net to get the ID or information from the URL in angular js.
}
});
當我使用RouteParams我的調試器沒有打。
不working.Actually當我使用$ routeParam在控制我的流程breaking.It沒有控制器功能 – user3714087
你可以試試,在你的控制器聲明中去,換款'angular.module(「UserInformationApp」,[]) 'for angular.module('UserInformationApp')'? 「我的流量突破」不是錯誤消息。你也可以閱讀文檔https://docs.angularjs.org/api/ngRoute/service/$routeParams –