├── LICENSE.md ├── README.md ├── bower.json └── src └── directives └── ng-flags.js /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 Asaf David 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ng-flags - AngularJS country flags directive 2 | ======== 3 | 4 | Simple directive for country flags, 5 | The directive takes country iso code and creates a thumbnail of the country's flag. 6 | 7 | 8 | ## Usage 9 | 1. Add ng-flag.js to your main file (index.html) 10 | 11 | 2. Set `ngFlag` as a dependency in your module 12 | ```javascript 13 | var myapp = angular.module('myapp', ['ngFlag']) 14 | ``` 15 | 16 | 3. Add the following line to the head section of your main file 17 | ```code 18 | 19 | ``` 20 | 21 | 4. Start drawing flags 22 | ```html 23 | 24 | 25 | * 32x32 thumbnails are also supported, just add the following line to your head: 26 | 27 | ```code 28 | 29 | ``` 30 | 31 | And and specify the wanted sizein your html: 32 | ```html 33 | 34 | ``` 35 | 36 | 37 | [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/asafdav/ng-flags/trend.png)](https://bitdeli.com/free "Bitdeli Badge") 38 | 39 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ng-flags", 3 | "version": "0.0.2", 4 | "main": "src/directives/ng-flags.js", 5 | "dependencies": { 6 | "angular": "~1.0.4" 7 | }, 8 | "devDependencies": {} 9 | } 10 | -------------------------------------------------------------------------------- /src/directives/ng-flags.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ng-flags module 3 | * Turns country ISO code to flag thumbnail. 4 | * 5 | * Author: asafdav - https://github.com/asafdav 6 | */ 7 | angular.module('ngFlag', []). 8 | directive('flag', function() { 9 | return { 10 | restrict: 'E', 11 | replace: true, 12 | template: '', 13 | scope: { 14 | country: '@', 15 | size: '@' 16 | }, 17 | link: function(scope, elm, attrs) { 18 | // Default flag size 19 | scope.size = 16; 20 | 21 | scope.$watch('country', function(value) { 22 | scope.country = angular.lowercase(value); 23 | }); 24 | 25 | scope.$watch('size', function(value) { 26 | scope.size = value; 27 | }); 28 | } 29 | }; 30 | }); 31 | --------------------------------------------------------------------------------