ng:areq:Argument' AppController'不是一个功能,未定义

时间:2016-02-22 14:08:24

标签: angularjs

JS:

(function () {
    'use strict';

    var app = angular.module('appModule',
              [
                'ngRoute',                
                'winjs'
              ]);

    app.controller('AppController', function ($scope) {
        $scope.splitViewElement = document.getElementById('splitView');
    });   
})();

HTML

<!DOCTYPE html>
<html ng-app>
<head>
    <meta content="IE=edge, chrome=1" http-equiv="X-UA-Compatible" />
    <title>Index</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, 
    maximum- scale=1" />

    <script src="lib/angular/angular.min.js"></script>
    <script src="lib/angular-route/angular-route.min.js"></script>
    <link href="lib/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet" />
    <script src="lib/jquery/dist/jquery.js"></script>
    <script src="app/app-main.js"></script>
    <script type="text/javascript" 
    src="app/device/device-main.js"></script>
</script>
</head>

<body ng-controller="AppController as app">
    <div>
        <win-split-view-pane-toggle split-view="splitViewElement">
        </win-split-view-pane-toggle>
        <win-split-view id="splitView">
            <win-split-view-pane>
                SplitView Navigation Pane
                <win-split-view-command label="'Home'" 
                icon="'home'" on-invoked="goToHome()"></win-split-view-command>
                <win-split-view-command label="'Settings'" 
                icon="'settings'" on-invoked="goToSettings()">
            </win-split-view-command>
        </win-split-view-pane>
        <win-split-view-content>SplitView Content Area
        </win-split-view-content>
    </win-split-view>
</div>

</body>
</html>

包含了包含上述JS代码的&#34; app-main.js&#34;,有人可以检查并告诉我上述错误的原因。

1 个答案:

答案 0 :(得分:0)

您应该在ng-app中初始化您的应用。喜欢这个

<html ng-app="appModule">

然后它会起作用。

if the ngApp directive were not placed on the html element then the document would not be compiled, the AppController would not be instantiated

请参阅angularjs文档以参考此https://docs.angularjs.org/api/ng/directive/ngApp