这是我的Html
<body ng-controller="StoreController as store">
...........
<section ng-controller="PanelController as panel">
<ul class="nav nav-pills"">
<li ng-class="{active:panel.isSelected(1)}">
<a href="#" ng-click="panel.selectTab(1)">Description</a>
</li>
<li ng-class="{active:panel.isSelected(2)}">
<a href="#" ng-click="panel.selectTab(2)">Specification</a>
</li>
<li ng-class="{active:panel.isSelected(3)}">
<a href="#" ng-click="panel.selectTab(1)">Reviews</a>
</li>
</ul>
<div class="panel" ng-show="panel.isSelected(1)" >
<h4>Description</h4>
<p>{{product.description}}</p>
</div>
<div class="panel" ng-show="panel.isSelected(2)">
<h4>Specification</h4>
<p>Enter the product specification here</p>
</div>
<div class="panel" ng-show="panel.isSelected(3)">
<h4>Review</h4>
<p>Product review goes here.</p>
</div>
</section>
</div>
<body>
这是我的Js文件,我遇到的问题是在添加PanelController之后,但我找不到它的错误
(function(){
var app= angular.module("store",[]);
app.controller("StoreController", function(){
this.products = gems;
});
app.controller("PanelController", function(){
this.tab = 1;
this.selectTab = function(setTab){
this.tab = setTab;
};
this.isSelected = function(checkedTab){
return this.tab === checkedTab;
};
});
var gems=[
{
name:'Ruby',
price:1000000,
description:'It originally .......... ',
images:
{
thumb:'red.jpg',
full :'blue.jpg'
},
canPurchase:true,
},
.......
]
})();
当我添加PanelController时出现此错误,任何人都可以帮助我吗? 提前谢谢
答案 0 :(得分:0)
这个错误几乎总是与事实相关,即
ng-app
中指定的根模块,或.js
。 我在这里采取了你的片段 - 他们正在按原样工作:
http://plnkr.co/edit/WUeFelbaMrrRebQZjpWg?p=info
使用ng-app的唯一扩展如下:
<!DOCTYPE html>
<html ng-app="store">
<head>...</head>
<body ng-controller="StoreController as store">
...