3

工作我要去坚果,这是这么小的事情,但我无法找到一个解决方案... 我有这个js文件(angularjs应用中的开头初始化HTML文档)NG重复不与温泉UI

app.controller('slidingMenuCtrl', function($scope) { 
    $scope.categories = [ 
     {title: 'Festas', icon: 'ion-ios-pint', notifications: 3}, 
     {title: 'Palestras', icon: 'fa-microphone', notifications: 0} 
    ]; 
    $scope.test = 'aaa'; 
}); 
在我的HTML

与NG-重复DIV说明不了什么,但如果没有它,一个显示 'AAA' 正确

和地方,为什么呢?

回答

4

ons-template模板不支持ng-controller指令,基本上它需要一个想法来处理模板,然后处理,如果我们问模板在http返回注册ons-templateid,在这里你有menu.html

你可以通过具有script标签与text/ons-template类型有做同样的事情作为。它的角度正好相同type/ng-template

模板

<script type="text/ons-template" id="main.html"> 

    ...content here... 

</script> 

添加ng-controller超过ons-page将使它通过实例controller工作规定ng-controller指令。

代码

<ons-page ng-controller="slidingMenuCtrl"> 
    <div ng-repeat="x in categories"> 
     {{x.title}} 
    </div> 
    <div> 
     {{test}} 
    </div> 
</ons-page> 
+1

谢谢你,我不知道。我试图调用插件页面的控制器,但该控制器甚至不那么认可。但是我发现这个问题,我是初始化插件和单独angularjs,我不应该 – user3820203

+1

@ user3820203但代码,你必须added..has我纠正..反正这个问题。谢谢 :) –