前角pression一个脚本标签中工作 [英] angular expression working inside a script tag

查看:153
本文介绍了前角pression一个脚本标签中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何得到一个前角pression一个脚本标签中工作...我是pretty新的这个和需要帮助吗?
这是我的Java脚本code的例子:

 <脚本ID =模式-2.HTML类型=文/ NG-模板>
< D​​IV CLASS =模式透明>
< D​​IV CLASS =一卡通>
< I类=图标离子ios7近距离特写模式NG点击=closeModal(2)>< / I>
< D​​IV CLASS =项项除法>
{{card.title}}
< / DIV>
< D​​IV CLASS =项项文本换行>
{{card.details}}
< / DIV>
< / DIV>
< / DIV>
< / SCRIPT>

下面是我的数组的例子:

  .controller('TodoCtrl',函数($范围,$ ionicPopup,$超时,$ ionicModal,$ ionicSideMenuDelegate){  $ scope.cardss =
  {ID:1,标题:弗兰克,SRC:IMG / Frank.png',详细信息:'!这将是产品说明},
  {ID:2,标题:'忠',SRC:IMG / Generali.png',详细信息:'!这将是产品说明},
  {ID:3,标题:约翰·刘易斯,SRC:IMG / JohnLewis.png',详细信息:'!这将是产品说明},
  ];


解决方案

有什么特别WRT里面使用部分模板AngularJS前pressions的。

前面已经说了你的模型实际上是阵列 - 所以你必须通过使用的 NG-重复是这样的:

 < UL>
    <李NG重复=牌牌>
        卡ID:{{card.id}}
        卡标题:{{card.title}}
        卡的详细信息:{{card.details}}
    < /李>
< / UL>

请参见的jsfiddle 例子。

How do I get an angular expression working inside a script tag... I am pretty new to this and need help? Here is an example of my java script code:

    <script id="modal-2.html" type="text/ng-template">
<div class="modal transparent">
<div class="card">
<i class="icon ion-ios7-close close-modal" ng-click="closeModal(2)"></i>
<div class="item item-divider">
{{card.title}}
</div> 
<div class="item item-text-wrap">
{{card.details}}
</div>
</div>
</div>
</script>

Here is an example of my array:

.controller('TodoCtrl', function($scope, $ionicPopup, $timeout, $ionicModal, $ionicSideMenuDelegate) {

  $scope.cardss = 
  {id:1, title:'Frank', src:'img/Frank.png',details:'This will be the products description!'},
  {id:2, title:'Generali', src:'img/Generali.png',details:'This will be the products description!'},
  {id:3, title:'John Lewis', src:'img/JohnLewis.png',details:'This will be the products description!'},
  ]; 

解决方案

There is nothing special wrt use of AngularJS expressions inside partial templates.

As already said your model is actually array - so you'll have to iterate through the items using ng-repeat like this:

<ul>
    <li ng-repeat="card in cards">
        Card id: {{card.id}}
        Card title: {{card.title}}
        Card details: {{card.details}}
    </li>
</ul>

Please see working JSFiddle example.

这篇关于前角pression一个脚本标签中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆