Wijmo ユーザーガイド > Angular JS ディレクティブ > AngularJS と wijcombobox |
この Angular 導入ガイドでは、HTML マークアップ、jQuery スクリプト、および AngularJS ディレクティブを使用して、wijcombobox を HTML プロジェクト内で使用する方法について学習します。
コントローラーとモデルをそれぞれ個別のファイルで設定する、より複雑なサンプルについては、弊社 Web サイト「AngularJS Directive Gallery」を参照してください。
ドロップダウンからマークアップをコピーします
任意のテキストエディタに貼り付けます。 |
コードのコピー |
---|---|
<!DOCTYPE HTML> <HTML ng-app="MyApp"> <head> </head> <body ng-controller="MyController"> </body> </HTML> |
ドロップダウンして参照コードをコピーし、<head> タグ内に貼り付けます
参照 |
コードのコピー |
---|---|
<!-- jQuery --> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js" type="text/javascript"></script> <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.0/jquery-ui.min.js" type="text/javascript"></script> <!--Theme--> <link href="http://cdn.wijmo.com/themes/aristo/jquery-wijmo.css" rel="stylesheet" type="text/css" /> <!--Wijmo Widgets CSS--> <link href="http://cdn.wijmo.com/jquery.wijmo-pro.all.3.20173.128.min.css" rel="stylesheet" type="text/css" /> <!-- Wijmo Scripts --> <script src="http://cdn.wijmo.com/jquery.wijmo-open.all.3.20173.128.min.js" type="text/javascript"></script> <script src="http://cdn.wijmo.com/jquery.wijmo-pro.all.3.20173.128.min.js" type="text/javascript"></script> <!-- Angular --> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.0/angular.min.js"></script> <script src="http://cdn.wijmo.com/interop/angular.wijmo.3.20173.128.min.js"></script> |
スクリプト |
コードのコピー |
---|---|
<script type="text/javascript"> var app = angular.module("MyApp", ["wijmo"]); function MyController($scope) { $scope.val = "PA"; $scope.states = [ { name: "Alabama", value: "AL" }, { name: "Alaska", value: "AK" }, { name: "Arizona", value: "AZ" }, { name: "Arkansas", value: "AR" }, { name: "California", value: "CA" }, { name: "Colorado", value: "CO" }, { name: "Connecticut", value: "CT" }, { name: "Delaware", value: "DE" }, { name: "Florida", value: "FL" }, { name: "Georgia", value: "GA" }, { name: "Hawaii", value: "HI" }, { name: "Idaho", value: "ID" }, { name: "Illinois", value: "IL" }, { name: "Indiana", value: "IN" }, { name: "Iowa", value: "IA" }, { name: "Kansas", value: "KS" }, { name: "Kentucky", value: "KY" }, { name: "Louisiana", value: "LA" }, { name: "Maine", value: "ME" }, { name: "Maryland", value: "MD" }, { name: "Massachusetts", value: "MA" }, { name: "Michigan", value: "MI" }, { name: "Minnesota", value: "MN" }, { name: "Mississippi", value: "MS" }, { name: "Missouri", value: "MO" }, { name: "Montana", value: "MT" }, { name: "Nebraska", value: "NE" }, { name: "Nevada", value: "NV" }, { name: "New Hampshire", value: "NH" }, { name: "New Jersey", value: "NJ" }, { name: "New Mexico", value: "NM" }, { name: "New York", value: "NY" }, { name: "North Carolina", value: "NC" }, { name: "North Dakota", value: "ND" }, { name: "Ohio", value: "OH" }, { name: "Oklahoma", value: "OK" }, { name: "Oregon", value: "OR" }, { name: "Pennsylvania", value: "PA" }, { name: "Rhode Island", value: "RI" }, { name: "South Carolina", value: "SC" }, { name: "South Dakota", value: "SD" }, { name: "Tennessee", value: "TN" }, { name: "Texas", value: "TX" }, { name: "Utah", value: "UT" }, { name: "Vermont", value: "VT" }, { name: "Virginia", value: "VA" }, { name: "Washington", value: "WA" }, { name: "West Virginia", value: "WV" }, { name: "Wisconsin", value: "WI" }, { name: "Wyoming", value: "WY" }]; }; </script> |
マークアップ |
コードのコピー |
---|---|
<p><label id="output">Where do you live?</label></p> <wij-combobox data-source="states" drop-down-height="150" drop-down-width="200" selected-value="val"> <data> <label bind="name"></label> <value bind="value"></value> </data> </wij-combobox> |