【问题标题】:AngularJS Ui-Router, views, and tabsAngularJS Ui-Router、视图和选项卡
【发布时间】:2014-12-29 14:56:39
【问题描述】:

好的,我在这里使用 ASP.NET MVC5 + AngularJS 1.3.8。

索引.vbhtml:

<div ng-controller="MainController">
    <tabset justified="true">
        <tab ng-repeat="t in tabs" heading="{{t.heading}}" select="go(t.route)" active="t.active"></tab>
    </tabset>
</div>
 <div ui-view="main"></div>

标签工作正常。

App.js:

App.config(function ($stateProvider, $urlRouterProvider, $locationProvider) {

//$locationProvider.html5Mode(true); // HTML5 Mode to remove hashbang, want to revist this later as it requires IIS rewrite rules

$urlRouterProvider.otherwise("/");

$stateProvider
// Main Page
.state('main', {
    abstract: true,
    url: '/',
    views: {
        'main': {
            templateUrl: '/',
            controller: 'MainController'
        }
    }
})

// Home page
.state('home', {
    url: '/home',
    views: {
        'main': {
            templateUrl: '/Home/Index',
            controller: 'HomeController'
        }
    }
})

// Requests Page
.state('requests', {
    url: '/requests',
    views: {
        'main': {
            templateUrl: '/Request/Index',
            controller: 'RequestController'
        }
    }
})

// Leave Requests page
.state('requests.leave', {
    url: '/leave',
    views: {
        'main': {
            templateUrl: '/Request/Leave',
            controller: 'LeaveController'
        }
    }
})
App.controller('RequestController', function ($scope, $state) {
$scope.loadComp = function () {
    $state.go('requests.comp');
};

$scope.loadOvertime = function () {
    $state.go('requests.overtime');
};

$scope.loadLeave = function () {
    $state.go('requests.leave');
};
});

好的,所以我想要完成的是,在我的请求选项卡上,我有三个按钮,当我单击其中一个按钮时,将父视图“主”替换为适当的状态。

我看到按钮单击时 URL 发生了变化,但没有呈现任何内容。

我通过 AJAX 从服务器获取我的部分视图没有任何问题,除了这些按钮点击 :(

我很想知道我做错了什么:) 谢谢!

FWIW:Angular UI-Router: child using parent's view 我一直在尝试重做这个,但没有运气......

【问题讨论】:

    标签: asp.net-mvc vb.net angularjs


    【解决方案1】:

    我会尝试像这样指向 templateUrl 中的真实模板:templateUrl: '/Request/Index.html'

    【讨论】:

      猜你喜欢
      • 2015-11-21
      • 2014-10-30
      • 1970-01-01
      • 2016-07-02
      • 2014-09-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多