当我在body标签上使用 ng-app =' myApp' 指令时,它会抛出' 元素[0] .setTabbarVisibility不是函数'错误。
如果我不包含ng-app,它可以正常工作。
为什么会这样?
{{1}}
答案 0 :(得分:0)
尝试在body标签之后编写javascript代码,它为我工作
<body ng-app="FirstProject" ng-controller="MainController">
<ons-tabbar>
<ons-tab label="tab1" page="tab1.html" active>
</ons-tab>
<ons-tab label="tab2" page="tab2.html">
</ons-tab>
</ons-tabbar>
<ons-template id="tab1.html">
<ons-page>
<p style="text-align: center;">
This is the first page.
</p>
</ons-page>
</ons-template>
<ons-template id="tab2.html">
<ons-page>
<p style="text-align: center;">
This is the second page.
</p>
</ons-page>
</ons-template>
</body>
<script>
var module=ons.bootstrap('myApp',['onsen']);
module.controller('MainController',function($scope){
console.log("Main controller");
});
</script>