Why populating ng-model inside forms should be followed by $scope.$apply?

前端 未结 2 1525
日久生厌
日久生厌 2021-01-28 04:45

I have a form:

2条回答
  •  一生所求
    2021-01-28 05:04

    Please see demo below

    You need to change name of your form from 'placeThis' to something else like 'placeThisForm' otherwise you overwriting $scope.placeThis values set in your controller.

    Please see demo below

    var app = angular.module('app', []);
    
    app.controller('homeCtrl', function($scope) {
    
      $scope.placeThis = {
        target: "One",
        name: "Tim"
    
      };
    
    
    });
    
    
    

提交回复
热议问题