【问题标题】:ionic ion-google-place ng-model undefined离子 ion-google-place ng-model 未定义
【发布时间】:2015-07-20 05:55:51
【问题描述】:

我正在尝试在我的 ion-google-place 指令中提交 ng 模型,但它总是记录未定义

查看:

<form ng-submit="submit()">

 <ion-google-place placeholder="Enter Address" ng-model="location" geocode-options="geocodeOptions"/>

 <button ng-click="submit()">Submit</button>

</form>

控制器:

$scope.submit = function(){
      var location = $scope.location;
     console.log(location);
     }

【问题讨论】:

  • 您在button 上错过了"ng-click
  • @Tushar 哦,对不起,但这不是真正的问题
  • 你没有在ng-clickbutton 上调用submit 函数
  • @Tushar 抱歉打错了.. 假设没有语法错误

标签: javascript angularjs ionic-framework google-places-api


【解决方案1】:

查看:

<form ng-submit="submit(location)">
   <ion-google-place placeholder="Enter Address" ng-model="location" geocode-options="geocodeOptions"/>
   <button ng-click="submit(location)">Submit</button>
</form>

控制器:

$scope.submit = function(location) {
    var loc = location;
    console.log(loc);
}

这应该可行。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-09-14
    • 1970-01-01
    • 2015-11-06
    • 1970-01-01
    相关资源
    最近更新 更多