我正在尝试使用带有HTML的select和options标记.数据正在使用ng-repeat,当用户从列表中选择一个项目并按下获取按钮时,我想将用户从选项列表中选择的内容传递给一个函数使用ng-click
HTML
<ul>
<li class="col-xs-4"><a href="#favourites">Favourites</a></li>
</ul>
<div ng-controller="favouritesController">
<select class="col-xs-12" name="weather">
<option ng-repeat="weatherList in weatherLists" ng-model="city">{{weatherList.place}}</option>
</select>
<div class="col-xs-12">
<button type="button" name="button" class="deleFav" ng-click="getFavWeather(city)">Get</button>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
Javascript代码
var myApp = angular.module('myApp', ['ngRoute'])
myApp.controller('favouritesController', function($scope, $http, $rootScope, $route, $location) {
$scope.getFavWeather = function(weatherList){
console.log("yes yes yes")
console.log($scope.city)
}
})
Run Code Online (Sandbox Code Playgroud)