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我糾正..反正這個問題。謝謝 :) –