我有一个angularJS应用程序和一个旧的经典asp应用程序,它将有一个指向新应用程序的链接。经典的asp应用程序会将更改的URL参数传递给angular应用程序。像这样。 http://testURL.com/Notes/PresentationHtml/index.html#/Main/11111111
无论我做什么,URL总是被截断为 http://testURL.com/Notes/PresentationHtml/index.html#/Main/
我使用的是ui-router而不是内置的$ routeProvider路由。 下面是我的路由配置,如果我在浏览器窗口中输入网址,它可以正常工作。
var myApplication = angular.module('myApplication', ['ui.router', 'ajoslin.promise-tracker', 'ngGrid']);
var root = '/';
var home = root + 'Notes';
var apiUrl = home + '/notesapi/Notes';
var htmlHome = home + '/PresentationHtml/';
myApplication.config(['$stateProvider', '$urlRouterProvider', function ($stateProvider, $urlRouterProvider) {
var index = {
name: 'index',
url: '/Main/:accountId',
templateUrl: htmlHome + 'Main.html'
};
var errorstate = {
name: 'errorstate',
url: '/ApiUnhandledError/:appCode',
templateUrl: htmlHome + 'ApiUnhandledError.html'
};
$stateProvider.state(index);
}]);
myApplication.run(function ($state) {
$state.go('index');
});
答案 0 :(得分:0)
在控制器中访问传入的变量解决了这个问题。我不确定为什么它最初没有工作可能与UI-Router有关。这是传入帐户ID参数后的代码。
if ($stateParams.accountId != null && $stateParams.accountId.trim() != '') {
$scope.qsAccountArg = $stateParams.accountId
messageFactory.setAccountId($scope.qsAccountArg);
} else {
$scope.qsAccountArg = '';
$scope.ShowAccountFilter = true;
}