我从api生成html,但我无法从数据绑定中获取它的值。 HTMLng-model在角js中不工作
<div class="content-fluid ng-scope" id="angular_template">
<div class="row">
<div class="col-md-6">
<label class="col-md-12">First Name</label>
<input type="text" ng-model="frm1.first_name" class="textboxStyle col-md-6 form-control" placeholder="first name">
</div>
<div class="col-md-6">
<label class="col-md-12">Last Name</label>
<input type="text" ng-model="frm1.last_name" class="textboxStyle col-md-6 form-control" placeholder="last name">
</div>
</div>
</div>
<input type="button" ng-click="save(frm1)" value="Submit" />
控制器:
mod.controller('CreateSimpleFormController', function($scope, $http) {
$http.get('<url>').success(function(response) {
var angularTemplate = response;// html string
document.getElementById("angular_template").innerHTML = angularTemplate;
}).error(function(error) {
console.log('error', error);
}).finally(function() {});
$scope.save = function(data){
console.log(data);
console.log($scope.frm1.first_name);
}
});
我得到未定义当我点击提交按钮。请帮助我出错的地方。
什么是未定义的? – adolfosrs
您没有提交表单,但是您在代码中使用了'type =“submit”'。尝试使用类型按钮的按钮,看看它是否工作。 –
尝试填充两个输入,然后按提交 – SuperComupter