如何在angularjs中使用旗帜获取国家/地区名称

时间:2015-12-15 06:46:37

标签: html angularjs

我想在国家标签上获得国旗。

 <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0-rc.0/angular.min.js"></script>  
 <script src="ng-flags.js"></script>
 <script src="script.js"></script>
 <body ng-app="validationApp" ng-controller="mainController" style="background-image:url('images/Assets/BG.png')">
 <label>COUNTRY</label><br>
 <select name="country">
 <option ><span flag="'us'" flag-size="f32">USA</span></option></select><br><br>
 </body>

声明ng-controller添加ng-flag的依赖。

 var validationApp = angular.module('validationApp', ['ngFlag']);

// create angular controller
  validationApp.controller('mainController', function($scope) {

    // function to submit the form after all validation has occurred    



});

1 个答案:

答案 0 :(得分:0)

假设您正在使用的ng-flags库是这个:https://github.com/asafdav/ng-flags

您只需按照说明操作......

Usage

Add ng-flag.js to your main file (index.html)

Set ngFlag as a dependency in your module

var myapp = angular.module('myapp', ['ngFlag'])
Add the following line to the head section of your main file

<link rel="stylesheet" type="text/css" href="http://cloud.github.com/downloads/lafeber/world-flags-sprite/flags16.css" />
Start drawing flags

<flag country="us" size="16"></flag>

* 32x32 thumbnails are also supported, just add the following line to your head:
<link rel="stylesheet" type="text/css" href="http://cloud.github.com/downloads/lafeber/world-flags-sprite/flags32.css" />
And and specify the wanted sizein your html:

  <flag country="us" size="32"></flag>