简体   繁体   English

AngularJS Ui路由器,视图和选项卡

[英]AngularJS Ui-Router, views, and tabs

Ok, I'm using ASP.NET MVC5 + AngularJS 1.3.8 here. 好的,我在这里使用ASP.NET MVC5 + AngularJS 1.3.8。

Index.vbhtml: Index.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>

Tabs are working fine. 选项卡工作正常。

App.js: 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');
};
});

Ok, so what I'm trying to accomplish is that on my Requests tab, I have three buttons, and when I click on one of those buttons, replace the parent view "main" with the appropriate state. 好的,所以我要完成的工作是在“请求”选项卡上,有三个按钮,然后单击其中一个按钮,将父视图“主”替换为适当的状态。

I see the URL change on the button click, but nothing renders. 单击按钮后,URL发生变化,但是没有任何显示。

I am getting my partial views back from the server via AJAX with no issues, except for these button clicks :( 我通过AJAX从服务器获取了部分视图,除了这些按钮单击之外,没有其他问题:(

I'd love to know what I'm doing wrong :) Thanks! 我很想知道我在做什么错:)谢谢!

FWIW: Angular UI-Router: child using parent's view I've been trying to rework this with no luck... FWIW: Angular UI-Router:使用父视图的孩子我一直在尝试重做,但是没有运气...

我要做的是尝试指向templateUrl中的真实模板,如下所示:templateUrl:'/Request/Index.html'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM