AngularJS: Uncaught Error: No module: GridCambiable

AngularJS: Uncaught Error: No module: GridCambiable

本文关键字:module GridCambiable No Error Uncaught AngularJS      更新时间:2023-09-26

我正在尝试遵循我在这里找到的教程和演示http://jsfiddle.net/scyrizales/pC9dH/

因此,这是我所做的代码片段

<div ng-app="GridCambiable" ng-controller="GridCambiableController">
    <div class="bar">
        <!-- These two buttons switch the layout varaible,
             which causes the correct UL to be shown. -->
        <a class="list-icon" ng-class="{active: isLayout('list')}" ng-click="setLayout('list')"></a>
        <a class="grid-icon" ng-class="{active: isLayout('grid')}" ng-click="setLayout('grid')"></a>
    </div>
    <!-- We have two layouts. We choose which one to show depending on the "layout" binding -->
    <ul ng-show="isLayout('grid')" class="grid">
        <!-- A view with big photos and no text -->
        <li ng-repeat="p in pics">
            <a href="{{p.link}}" target="_blank"><img ng-src="{{p.images.low_resolution.url}}" /></a>
        </li>
    </ul>
    <ul ng-show="isLayout('list')" class="list">
        <!-- A compact view smaller photos and titles -->
        <li ng-repeat="p in pics">
            <a href="{{p.link}}" target="_blank"><img ng-src="{{p.images.thumbnail.url}}" /></a>
            <p>{{p.caption.text}}</p>
        </li>
    </ul>
<标题>
app.controller('GridCambiableController', ['$scope', 'instagram' ,
function ($scope, instagram){
    // Layout por defecto
    $scope.layout = 'grid';
    $scope.setLayout = function(layout){
        $scope.layout = layout;
    };
    $scope.isLayout = function(layout){
        return $scope.layout == layout;
    };

当我启动代码时,我在我的chrome控制台得到这个错误

Uncaught Error: No module: GridCambiable
我的尝试失败了http://plnkr.co/edit/9BYKw45ZrIgVpbixRsAz?p=preview

请问为什么我在我的控制台上得到这个。谢谢。

您在包含angular.min.js之后没有包含script.js

在你的index.html:

<!--include angular-->
<script src="script.js"></script>

在控制器前添加:

var app = angular。模块("GridCambiable",[]);

替代:

角。模块("GridCambiable",[])。controller('GridCambiableController', ['$scope', 'instagram',函数($scope, instagram){

// Layout por defecto
$scope.layout = 'grid';
$scope.setLayout = function(layout){
    $scope.layout = layout;
};
$scope.isLayout = function(layout){
    return $scope.layout == layout;
};