Bonjour,
My ng-model doesn't change the $scope, I have always the same city, when I 
change my ng-model ?

template:

  <div class="loader" ng-show="loader">                                     
                                 
  </div>                                                                   
                                  
  <section>                                                                 
                                 
    <section class="panel padding-panel">                                   
                                 
    <form action="" method="get" accept-charset="utf-8"                     
                                 
      ng-submit="search()">                                                 
                                 
        <p>                                                                 
                                 
          <input class="text" type="text" placeholder="Search a city"       
                                 
          ng-model="city">                                                 
                                  
        </p>                                                               
                                  
        <p><input type="submit" class="submit" value="Search  →"></p>       
                                 
      </form>                                                               
                                 
      <div class="row-title">                                               
                                 
        [{{city}}]                                                         
                                  
      </div>                                                               
                                  
      <div class="row-title">                                               
                                 
        {{weather.city.name}} / {{weather.city.country}}                   
                                  
      </div>                                                               
                                  
    </section>                                                             
                                  
  </section>

Controlleur:

    //$scope.city='';                                                       
                               
     if ( typeof $scope.city !== undefined) {                               
                                
      $scope.city='Milan';                                                 
                                 
     }                                                                     
                                 
                                                                            
                                
     var url;                                                               
                                
     $scope.search = function () {                                         
                                 
      alert($scope.city);                                                   
                                
       url = 
"http://api.openweathermap.org/data/2.5/forecast?q="+$scope.city+"&mode=json&cnt=10";;
 
    
        $scope.loader = true;                                               
                                
        $http.get(url).success(httpSuccess).error( function () {           
                                 
          $scope.loader = false;                                           
                                 
          alert('Impossible de recuperer les informations');               
                                 
        });                                                                 
                                
     };                                                                     
                                
     httpSuccess = function (response) {                                   
                                 
      $scope.weather = response;                                           
                                 
      //alert($scope.weather.message + " / " + $scope.weather.city.name);
      alert($scope.city);                                                   
                                
      $scope.loader = false;                                               
                                 
     };

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to