Skip to content
very tiny and safe img for Angular 2
JavaScript TypeScript
Branch: develop
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
config
src
.gitignore
.travis.yml
LICENSE
README.md
index.ts
karma.conf.js
package.json
tsconfig.json
tslint.json
typedoc.json

README.md

ng2-safe-img Build Status

very tiny and safe img for Angular 2

Just consist from one structural directive - *safeSrc. And should be used with with :

<img *safeSrc="item.uri"/>

Example

Lets explain how does it work through example.

Here how should we use it

<img *safeSrc="item.uri"/>

if <item.uri> equal to 'https://placekitten.com/200/300' we will get

<img src="https://placekitten.com/200/300"/>

if <item.uri> is undefined or null we will get

<!--template bindings={
  "ng-reflect-src": null
}-->

so no any html elements will be there. What saves us from seeing something like this:

unsafe img with undefined uri

You can’t perform that action at this time.