angular.js - angular js 報錯 [$injector:modulerr] 模組注入錯誤
阿神
阿神 2017-05-15 17:11:24
0
3
750

html

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Document</title>


    <script src="angularJs/angular.min.js"></script>
    <script src="angularJs/angular-route.min.js"></script>
    <script src="app.js"></script>
    <script src="controller.js"></script>
    <link rel="stylesheet" href="semantic.min.css">
    <link rel="stylesheet" href="index.css">
</head>

<body ng-app="myapp">

    <p class="container">
        <p class="head">
            <p class="home"></p>
            <p class="logo">
                <a href="#">
                    <img src="img/logo@2x.png"> </a>
            </p>
            <p class="user-info">
                <!--                <button class="ui inverted button" onclick="alert()"></button>-->
            </p>
        </p>
        <p class="ui secondary vertical pointing menu leftbar">
            <a class="active item" href="#/user">
                    User
                </a>
            <a class="item" href="#/comments">
                    Comments
                </a>
            <a class="item" href="#/onlineclasses">
                   Online Classes
                </a>
            <a class="item" href="#/preschedule">
                   PreSchedule
                </a>
            <a class="item" href="#/fireman">
                   Fireman
                </a>
            <a class="item" href="#/qiangke">
                   抢课列表
                </a>
        </p>
        <p class="content">
            <p class="content-head">
                <p class="ui secondary pointing menu">
                    <a class="active item" href="#/user">
                    Students
                    </a>
                    <a class="item">
                    Families
                    </a>
                </p>
            </p>
            <p ng-view></p>
        </p>
    </p>

</body>

</html>

app.js

var app = angular.module('myapp', ['ngRoute'])
app.config(['$routeProvider', function ($routeProvider) {
    $routeProvider.when('/user', {
        templateUrl: 'user.html',
        controller: 'user'
    })
    $routeProvider.when('/conmments', {
        template: '这是用户'
    })
    $routeProvider.when('/onlineclasses', {
        template: '这是其他'
    })
    $routeProvider.when('/preschedule', {
        template: '这是用户'
    })
    $routeProvider.when('/fireman', {
        template: '这是其他'
    })
    $routeProvider.when('/qiangke', {
        template: '这是用户'
    })
    $routeProvider.when({
        redirectTo: '/user'
    });
}])

user.html

<p class="container" ng-controller="user">
    <p class="searchbox">
        <select class="ui dropdown" ng-options="x for x in gender">
        </select>
        <select class="ui dropdown" ng-options="x for x in age">
        </select>
        <select class="ui dropdown" ng-options="x for x in province">
        </select>
    </p>
</p>

controller.js

app.controller('user', function ($scope) {
    $scope.gender = ['-gender-', 'female', 'male'];
    $scope.age = ['-age-', ' < 5 ', '6 ', '7 ', '8 ', ' > 8 '];
    $scope.province = ['-province-','']
})

錯誤

阿神
阿神

闭关修行中......

全部回覆(3)
为情所困

程式碼裡沒有引入angular-route.js

世界只因有你

http://www.tuicool.com/articl...

看一下上面的教學吧,然後通常都這麼寫

angular.module('myapp', ['ngRoute'])
.config([
    '$routeProvider',
    function ($routeProvider) {
        $routeProvider
            .when('/home', {
                templateUrl: 'home.html',
                controller: 'HomeController'
            })
            .otherwise('/home')
    }
])
小葫芦

app模組找不到,看看注入什麼的

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板