ng-model is undefined in controller

前端 未结 5 981
醉话见心
醉话见心 2020-12-10 03:56

I\'m using ionic and I have the following view:


  

        
5条回答
  •  悲&欢浪女
    2020-12-10 04:13

    I had exact the same issue recently and that's probably a solution: https://stackoverflow.com/a/22768720/552936

    Modified quote:

    "If you use ng-model, you have to have a dot in there."
    Make your model point to an object.property and you'll be good to go.

    Controller

    $scope.formData = {};
    $scope.login = function () {
      console.log("User logged in with membership no: " + $scope.formData.membershipNo +
      "\n and password: " + $scope.formData.password);
     }
    

    Template

    
    
    

提交回复
热议问题