ng-fallback-src
Fallback image src if you need it
Last updated 5 years ago by jakxz .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install ng-fallback-src 
SYNC missed versions from official npm registry.

ng-fallback-src npm version

replace 404s with some default asset, for better [empty] states.

Install

npm install --save ng-fallback-src

bower install --save ng-fallback-src

Example Usage

This was originally meant for img tags only, but theoretically it could work for any element with a src tag. This theory is untested so use at your own risk.

<img ng-src="{{someFlakyVar}}" fallback-src="{{someReliableUrl}}" />

Note: if someFlakyVar can be falsy, you'll need to account for it separately, e.g.

<img ng-src="{{someFlakyVar || someReliableUrl}}" 
  fallback-src="{{someReliableUrl}}" />

since most browsers won't actually fire the error event if the src is empty.

Contributing

The most obvious things right now are

  • [ ] tests
  • [ ] adding files so this can be published to other package managers.
  1. Fork

  2. Create your feature branch: git checkout -b my-new-feature

  3. Commit your changes: git commit -am 'Add some feature'

  4. Push to the branch: git push origin my-new-feature

  5. Create a new Pull Request

Credits

  • @concertcoder [Chris Gosselin]: version 0.x and helping correct a potential memory leak
  • @nexus-uw [Simon Ramsay]: pointing out that @concertcoder wrote this once upon a time

Current Tags

  • 1.0.2                                ...           latest (5 years ago)

3 Versions

  • 1.0.2                                ...           5 years ago
  • 1.0.1                                ...           5 years ago
  • 1.0.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (1)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |