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?
Definition and UsageThe data-* attribute consist of two parts: The attribute name should not contain any uppercase letters, and must be at least one character long after the prefix "data-" The attribute value can be any string.
You initialize a variable using the equals sign (=). You can read it as “the value of the variable on the left should be the data on the right”: var name = "Tom"; “Tom” is a string - a collection of letters.
The <var> HTML element represents the name of a variable in a mathematical expression or a programming context. It's typically presented using an italicized version of the current typeface, although that behavior is browser-dependent.
The <var> element in HTML defines a text as a variable and can be used to define variables of a mathematical expression or variables of a piece of code. The text enclosed in the <var> element is normally displayed in italics. Note: The <var> element supports all global attributes and event attributes.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With