簡體   English   中英

ui網站中的ui路由器

[英]ui router in angular website

我是有角度的初學者,我遵循了ui-router文檔教程,但仍然無法正常工作。 我想在我的index.html中使用ui-router顯示我的Organization.html和header.html。 但沒有任何效果,我的控制台中沒有出現任何錯誤

這是我的index.html

<html ng-app="starter">
    <head>
<script src="node_modules/angular/angular.min.js"></script>
<script src="node_modules/jquery/dist/jquery.min.js"></script>
<script src="node_modules/angular-ui-router/release/angular-ui-router.js"></script>
<script src="node_modules/angular-route/angular-route.js"></script>
<script src="js/app.js"></script>
<script src="js/controller.js"> </script>
<script src="js/services.js"> </script>

<body ng-controller="homeCtrl">
    <div ui-view></div>
</body>

這是我的app.js:

var myapp = angular.module('starter', [ 'starter.controllers','ngRoute','ui.router'])
myapp.config(function($stateProvider, $urlRouterProvider){

    $stateProvider

        state('app', {
            abstract: true,
            cache:false,
            templateUrl: '../views/header.html',

        }).
        state('app.single', {
            templateUrl: '../views/single_user.html',
            controller: 'usersingleCtrl'
        }).
        state('app.organization', {
            templateUrl: '../views/organization',
            controller: 'homeCtrl'
        })
    $urlRouterProvider

        .otherwise("app.organization")

    });

我的header.html和organization.html僅包含簡單的html。

如果您需要查看我的樹形視圖:

在此處輸入圖片說明

嘗試這個:

$stateProvider.state('app',{
        url: '',
        abstract: true
        templateUrl: '../views.html',
        controller: 'viewCtrl',
    })
    .state('app.single', {
        url: '/single',
        templateUrl: '../views/single_user.html',
        controller: 'usersingleCtrl'
    })

我處理了我的問題,我們只需在其中調用一次'ui.router'

myapp = angular.module('starter', [ 'starter.controllers','ngRoute','ui.router'])

我的錯誤是在控制器中調用'ui.router' ,這會導致覆蓋問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM