I was working on an Angular.JS tutorial and I am in step 6 . This lesson shows the following code snippet:
<ul class="phones"> <li ng-repeat="phone in phones | filter:query | orderBy:orderProp" class="thumbnail"> <a href="#/phones/{{phone.id}}" class="thumb"><img ng-src="{{phone.imageUrl}}"></a> <a href="#/phones/{{phone.id}}">{{phone.name}}</a> <p>{{phone.snippet}}</p> </li> </ul>
The following is explained:
We also added ... the ngSrc directive. This directive prohibits the browser from taking the angular {{expression}} markup literally and initiating a request for an invalid url / app / {{phone.imageUrl}}, which it would execute if we only specified the attribute binding in the regular src () attribute. Using the ngSrc directive prevents the browser from making an HTTP request to an invalid location.
So, what he says is that the img element should use the Angular.JS ngSrc special directive so that it can parse the double curly braces correctly. But they cannot explain why element a does not require the same special directive.
<a href="#/phones/{{phone.id}}">
What's going on here? href can correctly parse double curly braces, but src can't? Why?
AngularJS docs are a great place to look for this type of information.
http://docs.angularjs.org/api/ng/directive/ngSrc
Angular {{hash}} src right: URL {{hash}} Angular {{hash}}. ngSrc .
ng-href:
ng-href
http://docs.angularjs.org/api/ng/directive/ngHref
Angular , {{hash}} href, URL-, , Angular {{hash}} . Angular , , , 404.
, , , URL-:
<a href="#/phones/{{ phone.id }}">
URL- , Angular . Angular, {{ phone.id }}, .
{{ phone.id }}
? , , . , .
, , .
, , href ( , , ), , , , , , , src.
, DOM , angular ( DOM angular), angular /, . {{phone.imageUrl}}, , .
{{phone.imageUrl}}
ng-src src angular.
Source: https://habr.com/ru/post/1529089/More articles:https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1529084/can-you-pass-compiler-flags-to-dart2js-via-dart-editor&usg=ALkJrhiumDSVYhdOaqwPyDbvWvothfi7CgPivot Command Crashing on Multiple CLR Aggregate Function Parameters ... Why? - sqlUsing Optware packages and startup scripts on a dd-wrt router - linuxHow to associate a local context block with a global context in Rebol2? - scopingJMSSerializer exception in self reference group - symfonyIOS UIWebview alternative - does the browser have a web kite that we can use as a non-Safari web browser? - safariHow to make the background position fixed and centered? - htmlPandas DataFrame Algorithm - pythonSet column differences between data frames - pythonSuddenly NPM starts installing -globally in / usr / lib / node_modules, why, where? - npmAll Articles