这是我的HTML代码,但我认为ng-init不起作用。
<div ng-init="accordion=1">
<h3 class="accordion" ng-class="{active:accordion==1}">
<a href ng-click="accordion = 1">Section 1</a>
</h3>
<p class="accordion-content" ng-show="accordion==1">Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using</p>
<h3 class="accordion" ng-class="{active:accordion==2}">
<a href ng-click="accordion = 2">Section 2</a>
</h3>
<p class="accordion-content" ng-show="accordion==2">It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using</p>
<h3 class="accordion" ng-class="{active:accordion==3}">
<a href ng-click="accordion = 3">Section 3</a>
</h3>
<p class="accordion-content" ng-show="accordion==3">There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form</p>
</div>
我希望这可能希望第一次工作如下,但它没有正常工作
但是它显示了这样。
我确定js和样式工作可能没有问题。
请看这里。 https://jsfiddle.net/koaqayb3/11/
我已经有一个模块,想知道如何整合这两个模块。
var module = angular.module(&#39; myApp&#39;,[&#39; ngAnimate&#39;,&#39; ngTouch&#39;,&#39; ngScrollbars&#39;,&#39; ;&#39;]);
var app = angular.module(&#39; myApp&#39;,[]);
提前致谢。
答案 0 :(得分:0)
为你修好了。您声明您的模块对其他模块有一些依赖关系,而这些模块并未包含在您的小提琴中。我刚刚删除了模块声明中的依赖项,如下所示:
var module = angular.module('myApp', []);
答案 1 :(得分:0)
由于
中定义的模块依赖性,您的小提琴无法正常工作 var module = angular.module('myApp', ['ngAnimate', 'ngTouch','ngScrollbars']);
应用程序无法将'ngAnimate', 'ngTouch','ngScrollbars'
这些依赖项放在你的小提琴中删除它们,它似乎工作正常。
希望有所帮助