首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >角$injector:modulerr模块误差

角$injector:modulerr模块误差
EN

Stack Overflow用户
提问于 2016-02-29 08:17:57
回答 2查看 87关注 0票数 1

我不知道是什么导致了这个错误:单击以查看错误

我正在尝试创建一个动态的web应用程序。我需要本地服务器来运行这个应用程序吗?目前我不使用任何本地服务器。

HTML:

代码语言:javascript
运行
复制
<div class = "body" ng-controller = "app">
  <div class = "column2">
    <div class = "sectionName">
       <span class = "sectionName-Span">{{ page.title() }}</span>
       <div class = "container">
          <ng-view>Something went wrong</ng-view>
       </div>
    </div>
  </div>
  <script type=text/ng-template id=profile.html>
     I'm Lalinda Sampath Dias
  </script>

Controller.js:

代码语言:javascript
运行
复制
var application = angular.module('mainApp', ['appServices'])
    .config(['$routeProvider', function($routeProvider) {
        $routeProvider.
                when('/tab1', {templateUrl: 'profile.html',   controller: HomeCtrl}).
                when('/tab2', {templateUrl: 'list.html',   controller: ListCtrl}).
                otherwise({redirectTo: '/tab1'});
}]);


/* Controllers */

function MainCtrl($scope, Page) {
    console.log(Page);
    $scope.page= Page; 
}

function HomeCtrl($scope, Page) {
    Page.setTitle("Welcome");
}


function ListCtrl($scope, Page, Model) {
    Page.setTitle("Items");
    $scope.items = Model.notes();

}

function DetailCtrl($scope, Page, Model, $routeParams, $location) {
    Page.setTitle("Detail");
    var id = $scope.itemId = $routeParams.itemId;
    $scope.item = Model.get(id);
}

function SettingsCtrl($scope, Page) {
    Page.setTitle("Settings");
}

/* Services */

angular.module('appServices', [])

        .factory('Page', function($rootScope){
            var pageTitle = "Untitled";
            return {
                title:function(){
                    return pageTitle;
                },
                setTitle:function(newTitle){
                    pageTitle = newTitle;
                }
            }
        })

        .factory ('Model', function () {
            var data = [
                {id:0, title:'Doh', detail:"A dear. A female dear."},
                {id:1, title:'Re', detail:"A drop of golden sun."},
                {id:2, title:'Me', detail:"A name I call myself."},
                {id:3, title:'Fa', detail:"A long, long way to run."},
                {id:4, title:'So', detail:"A needle pulling thread."},
                {id:5, title:'La', detail:"A note to follow So."},
                {id:6, title:'Tee', detail:"A drink with jam and bread."}
            ];
            return {
                notes:function () {
                    return data;
                },
                get:function(id){
                  return data[id];
                },
                add:function (note) {
                    var currentIndex = data.length;
                    data.push({
                        id:currentIndex, title:note.title, detail:note.detail
                    });
                },
                delete:function (id) {
                    var oldNotes = data;
                    data = [];
                    angular.forEach(oldNotes, function (note) {
                        if (note.id !== id) data.push(note);
                    });
                }
            }
});

编辑:

代码语言:javascript
运行
复制
<body ng-app = "mainApp">
        <div id = "background-div">
            <div class = "header">
                <div class = "ham-icon">
                    <img src = "images/ham-icon.png">
                </div>
                <div class = "logo">
                    <span class = "google-logo">Lalinda</span><span class = "hangouts-logo"> Sampath</span>
                </div>
                <div class = "profile-data">
                </div>
            </div>
            <div class = "body" ng-controller = "app">
                <div class = "column1">
                    <div class = "tab1">
                        <a href = "#/tab1"><img src = "images/people-icon.png"></a>
                    </div>
                    <div class = "tab2">
                        <a href = "#/tab2"><img src = "images/chat-icon.png"></a>
                    </div>
                    <div class = "tab3">
                        <a href = "#/tab3"><img src = "images/phone-icon.png"></a>
                    </div>
                    <div class = "tab4">
                        <a href= "#/tab4"><img src = "images/other-icon.png"></a>
                    </div>
                </div>
                <div class = "column2">
                    <div class = "sectionName">
                        <span class = "sectionName-Span">{{ page.title() }}</span>
                        <div class = "container">
                            <ng-view>Something went wrong</ng-view>
                            <!--input type = "text" ng-model = "name"-->
                        </div>
                    </div>
                </div>
                <script type=text/ng-template id=profile.html>
                    I'm Lalinda Sampath Dias
                </script>
                <div class = "column3">
                    <div classs = "user-greet">
                        <span class = "user-greet-span">Hi, Guest</span>
                    </div>
                    <div class = "det">
                        <span class = "det-span">Get started by calling or messaging a friend below</span>
                    </div>
                    <div class = "functional-area">
                        <div class = "video-call">
                        </div>
                        <div class = "phone-call">
                        </div>
                        <div class = "message">
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </body>
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-02-29 15:21:00

我自己想出了答案。当将ngRoute作为依赖项添加时,我们必须加载ngRoute.js文件。你可以从网上下载。

这是Google:https://ajax.googleapis.com/ajax/libs/angularjs/1.3.5/angular-route.js

票数 0
EN

Stack Overflow用户

发布于 2016-02-29 08:19:49

您需要添加ngRoute作为依赖项,如下所示

代码语言:javascript
运行
复制
var application = angular.module('mainApp', ['ngRoute','appServices'])
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35694723

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档