【问题标题】:Link from Classic asp app to an AngularJS app with URL parameters使用 URL 参数从经典 asp 应用程序链接到 AngularJS 应用程序
【发布时间】:2014-05-27 21:54:58
【问题描述】:

我有一个 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 路由。 下面是我的路由配置,如果我在浏览器窗口中输入 url,它就可以正常工作。

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');
});

【问题讨论】:

标签: angularjs angular-ui-router


【解决方案1】:

访问控制器中传入的变量解决了这个问题。我不确定为什么它最初无法正常工作可能与 UI-Router 有关。这是我传入account id参数后的代码。

if ($stateParams.accountId != null && $stateParams.accountId.trim() != '') {
    $scope.qsAccountArg = $stateParams.accountId
    messageFactory.setAccountId($scope.qsAccountArg);
} else {
    $scope.qsAccountArg = '';
    $scope.ShowAccountFilter = true;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-09-03
    • 1970-01-01
    • 1970-01-01
    • 2014-06-03
    • 1970-01-01
    • 2018-10-29
    • 2012-12-09
    相关资源
    最近更新 更多