Dart Documentationangular.directiveNgSourceDirective

NgSourceDirective class

In browser some attributes have network side-effect. If the attribute has {{interpolation}} in it it may cause browser to fetch bogus URLs.

Example: In <img src="{{username}}.png"> the browser will fetch the image http://server/{{username}}.png before Angular has a chance to replace the attribute with data-bound url.

For this reason we provide ng-prefixed attributes which avoid the issues mentioned above as in this example: <img ng-src="{{username}}.png">.

The full list of supported attributes are:

  • ng-href
  • ng-src
  • ng-srcset
@NgDirective(selector: '[ng-href]',   map: const {'ng-href':   '@href'})
@NgDirective(selector: '[ng-src]',    map: const {'ng-src':    '@src'})
@NgDirective(selector: '[ng-srcset]', map: const {'ng-srcset': '@srcset'})
class NgSourceDirective {
 NodeAttrs attrs;
 NgSourceDirective(NodeAttrs this.attrs);

 set href(value)   => attrs['href']   = value;
 set src(value)    => attrs['src']    = value;
 set srcset(value) => attrs['srcset'] = value;

}

Constructors

new NgSourceDirective(NodeAttrs attrs) #

Creates a new Object instance.

Object instances have no meaningful state, and are only useful through their identity. An Object instance is equal to itself only.

docs inherited from Object
NgSourceDirective(NodeAttrs this.attrs);

Properties

NodeAttrs attrs #

NodeAttrs attrs

dynamic set href(value) #

set href(value)   => attrs['href']   = value;

dynamic set src(value) #

set src(value)    => attrs['src']    = value;

dynamic set srcset(value) #

set srcset(value) => attrs['srcset'] = value;