AngularJS: How to set default value to ng-model=“searchText”?

后端 未结 5 1719
遥遥无期
遥遥无期 2020-12-29 07:02

I am unable to set a default value to ng-model=\"searchText\". Here is the code I am using
<

5条回答
  •  长发绾君心
    2020-12-29 07:33

    1st Solution: is to simply init the searchText in the controller.

    App.controller('mainController',['$scope', function($scope) {
       $scope.searchText  = "can you see me";
    }]);
    

    2nd Solution: is to use ng-init insteat of value

    
    

提交回复
热议问题