Can I declare a variable in html?

Given

 <li>Document Printing - 
<a href="http://{{displaySandbox()}}/{{displayCase()}}/PrintingService/DocumentPrintingService.svc">
 <span ng-class="{true:'value',false:'invalid'}[(sandbox && validcase())==true]">http://<span class="sandbox">{{displaySandbox()}}</span>.companyname.com/<span class="case">{{displayCase()}}</span>/PrintingService/DocumentPrintingService.svc</span></a> 
<span ng-bind-html-unsafe="getUrl('/PrintingService/DocumentPrintingService.svc')">
</span>
</li>

I would like to declare something like to wrap this in

<div ng-var="subPath=/PrintingService/PrintingService.svc>

so that anything inside that scope would be able to say

    <li>Document Printing - 
<a href="http://{{displaySandbox()}}/{{displayCase()}}{{subPath}}">
 <span ng-class="{true:'value',false:'invalid'}[(sandbox && validcase())==true]">http://<span class="sandbox">{{displaySandbox()}}</span>.companyname.com/<span class="case">{{displayCase()}}</span>{{subPath}}</span></a> 
<span ng-bind-html-unsafe="getUrl(subPath)">
</span>
</li>

Is there a way to declare a scope (for a variable or 'constant' if you will), via angular.js in html?


Using ng-init , you can initialize a value as below:

 <data ng-init="subPath= '/PrintingService/PrintingService.svc'"/>

However, it is better to use controller in such cases.

ng-init doc

链接地址: http://www.djcxy.com/p/73674.html

上一篇: 如何在Oracle中创建不属于“由sys拥有”的表?

下一篇: 我可以在html中声明一个变量吗?