IONIC 和 angularjs:在导航组件中使用 angular-ui-route 时没有任何反应

IONIC and angularjs: Nothing happends when using angular-ui-router in navigation component

最近按照一个关于在ionic中使用导航的说明,但是我测试了但没有用,我真的找不到哪里错了。下面是源文件,只有两个,一个是index.html,一个是app.jsindex.js的内容:

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
    <title></title>

    <link href="lib/ionic/css/ionic.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">
    <script src="lib/ionic/js/ionic.bundle.js"></script>

    <!-- cordova script (this will be a 404 during development) -->
    <script src="cordova.js"></script>
    <!-- your app's js -->
    <script src="js/app.js"></script>
</head>

<body ng-app="starter">
    <ion-nav-bar class="bar-positive">
        <ion-nav-back-button class="button-clear">
            <i class="ion-arrow-left-c"></i> Back
        </ion-nav-back-button>
    </ion-nav-bar>
    <ion-nav-view></ion-nav-view>
    <script type="text/ng-template" id="todos.html">
        <ion-view title="Todos">
            <ion-content>
                <ion-list>
                    <ion-item ng-repeat="todo in todos" class="item item-icon-right" ui-sref="app.todos.detail({todo: $index})">
                        <span ng-class="{done: todo.done}">{{todo.title}}</span>
                    </ion-item>
                </ion-list>
            </ion-content>
        </ion-view>
    </script>
    <script type="text/ng-template" id="todo.html">
        <ion-content>
            <div class="item">
                <p>{{todo.title}}</p>
            </div>

            <div class="item item-checkbox">
                <div>
                    <label class="checkbox">
                        <input type="checkbox" ng-model="todo.done">
                    </label>
                    Done
                </div>

            </div>
        </ion-content>
    </script>
</body>

</html>

app.js

的内容
var app = angular.module('starter', ['ionic'])
app.run(function($ionicPlatform) {
    $ionicPlatform.ready(function() {
        if (window.cordova && window.cordova.plugins.Keyboard) {
            cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
        }
        if (window.StatusBar) {
            StatusBar.styleDefault();
        }
    });
})

app.config(function($stateProvider, $urlRouterProvider) {
    $stateProvider.state('app.todos', {
        abstract: true,
        url: '/todos',
        template: '<ion-nav-view></ion-nav-view>'
    })

    $stateProvider.state('app.todos.index', {
        url: '',
        templateUrl: 'todos.html',
        controller: 'TodosCtrl'
    })

    $stateProvider.state('app.todos.detail', {
        url: '/:todo',
        templateUrl: 'todo.html',
        controller: 'TodoCtrl'
    })
})

app.factory('TodosService', function() {
    var todos = [{
        title: "Take out the trash",
        done: true
    }, {
        title: "Do laundry",
        done: false
    }, {
        title: "Start cooking dinner",
        done: false
    }]

    return {
        todos: todos,
        getTodo: function(index) {
            return todos[index]
        }
    }
})

app.controller('TodosCtrl', function($scope, TodosService) {
    $scope.todos = TodosService.todos
});

app.controller('TodoCtrl', function($scope, todo) {
    $scope.todo = todo
})

当我在命令行中输入 ionic serve 命令,然后输入 url 'http://xxxx/todos' 时,我什么也没看到,但应该会看到 todos.html,那么为什么会发生这种情况?

这条语句:

$stateProvider.state('app.todos', {

表示todosapp状态的子状态。但是你还没有配置一个名为 app 的状态,正如我从你的配置中看到的那样,你可能想要从每个 state 中删除 app.(不要忘记 ui-srefs ).