Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hugojosefson/image-url-for-angular
AngularJS directive for validating and figuring out width/height from an image url.
https://github.com/hugojosefson/image-url-for-angular
Last synced: 29 days ago
JSON representation
AngularJS directive for validating and figuring out width/height from an image url.
- Host: GitHub
- URL: https://github.com/hugojosefson/image-url-for-angular
- Owner: hugojosefson
- Created: 2013-05-09T11:55:26.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-07-02T13:52:37.000Z (over 11 years ago)
- Last Synced: 2024-11-08T22:40:34.631Z (about 2 months ago)
- Language: JavaScript
- Homepage:
- Size: 199 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: Readme.md
- Changelog: History.md
Awesome Lists containing this project
README
# image-url-for-angular
AngularJS directive for validating and figuring out width/height from an image url.
## Installation
### As a [component](https://github.com/component/component)
$ component install hugojosefson/[email protected]
In JS, to let it register its AngularJS module:
require("image-url-for-angular");
### With [Bower](http://bower.io/)
$ bower install hugojosefson-image-url-for-angular
In HTML:
### Old-school
$ wget https://raw.github.com/hugojosefson/image-url-for-angular/0.0.4/index.js -O image-url-for-angular-0.0.4.js
In HTML:
## API
One directive is registered, `imageUrl`, which you use like this:
...
Then the following are automatically kept up-to-date in the `$scope`:
myForm.screenshotUrl.$valid
myForm.screenshotUrl.$invalid
screenshot.width
screenshot.heightThe attributes `image-url-width-model` and `image-url-height-model` are each optional, but if
any of them is specified, the directive will keep the corresponding scope variable updated with the width/height.In case of an error, for example if the url is incorrect, or the image loaded is not a valid image, width and height
models are set to `null` and the form field's validity is set to invalid (specified as
`imageUrl`.)### Avoiding integration with form validity
If the url should not be part of the validity checking of its form (and by extension its parent form), use can specify
the attribute `image-url-integrate-with-form-validity="false"` on the `` tag. Then it will not set `$valid` nor
`$invalid`.For most cases you can check for a valid image by checking the width and/or height models instead, if you expect images
to be > 0 pixels.
## License
MIT