首页 > 代码库 > angularjs select
angularjs select
<html><head> <meta charset="utf-8"> <title>select 测试页面</title> <script src="http://www.mamicode.com/angular1.5.8.min.js"></script></head><body ng-app="app"><div ng-controller="getnames"> <p>with ng-option,这种方式可以取到一个对象</p> <select ng-model="selectedPeople" ng-options="people.name for people in peoples"></select> your choice is :{{selectedPeople.name}} <!--------------------------------------------------------------------------------------------> <p>without ng-option,这种方式只能取到一个字符串</p> <select ng-model="selectedName"> <option ng-repeat="people in peoples" value="http://www.mamicode.com/{{people.age}}">{{people.name}}</option> </select> your choice is :{{selectedName}}</div></body><script type="text/javascript"> var app =angular.module("app",[]); app.controller("getnames",function($scope){ $scope.peoples=[{name:"quannan",age:"100"},{name:"shenzhen",age:"1200"},{name:"shnaghai",age:"1003"}]; //$scope.names=["quannan","shenzhen","shanghai"]; });</script></html>
angularjs select
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。