angular expression working inside a script tag

后端 未结 2 1636
余生分开走
余生分开走 2021-01-28 10:01

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:

    

        
相关标签:
2条回答
  • 2021-01-28 10:45

    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.

    0 讨论(0)
  • 2021-01-28 11:00

    Here is an example how you can use your template:

    <div ng-include src="'modal-2.html'"></div>
    

    or use it with a button:

    <button ng-click="currentTpl='modal-2.html'">Show Modal</button>
    <div ng-include src="currentTpl"></div>
    

    The expression in the template then works as is usual.
    Here is an example.

    0 讨论(0)
提交回复
热议问题