Интересно, как подключить кнопку поиска к полю ввода.ng-click api search with AngularjS
controllers.js
angular.module('weatherApp.controllers', [])
.controller('weatherCtrl', function($scope, $http) {
$http.jsonp('http://api.openweathermap.org/data/2.5/find?q=' + $scope.SearchCity + '&type=like&APPID=&callback=JSON_CALLBACK')
.success(function(data){
console.log('success');
$scope.cities = data;
});
});
all.html
<input type="text" ng-model="SearchCity" placeholder="Search for city" />
<input type="submit" ng-click="Search" Value="Search" />
<tr ng-repeat="city in cities.list | limitTo: 10 | filter:SearchCity">
<td>{{city.name}}</td>
</tr>
app.js
angular.module('weatherApp', ['weatherApp.controllers', 'ngRoute']).config(['$routeProvider', function($routeProvider){
$routeProvider.when('/all', {templateUrl: 'templates/all.html', controller:'weatherCtrl'});
$routeProvider.otherwise({redirectTo: '/all'});
}]);
Я получаю это в консоли mozilla: success Object {data: Object, status: 200, headers: headersGetter/<(), config: Object, statusText: "load"}. он не перечисляет города, которые ищут хотя бы –
Попробуйте изменить эту строку на: console.log ('success', data.data); – manzapanza