如何在不使用 jquery 的情况下点击将 html 表单加载到 Angular 目标中?
到目前为止我的工作脚本,但我被困在
<html>
<head>
<script src="components/angular/angular.js"></script>
<script>
var app = angular.module("myapp", [])
app.controller("FormController",function($scope,$http) {
$scope.load = function() {
return $http({
method: "get",
url: "form.php"
}).then(function(response) {
$scope.form = response.data;
// how can I target id="form"??
});
};
}
);
</script>
</head>
<body>
<div ng-app="myapp" ng-controller="FormController">
<button ng-click="load()">Load</button>
<div id="form"> place the form here </div>
</div>
</div>
</body>
</html>
表单.php,
<form name="signup_form" novalidate ng-submit="signupForm()">
<input type="text" />
</form>
这是加载表单而不是使用 $http
的正确方法吗?
最佳答案
您还可以通过使用条件 ng-include 来使用此方法:
<div ng-include="'form.html'" ng-if="readyToLoadForm==true"></div>
关于javascript - 如何点击将html表单加载到 Angular 目标中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27450734/