所以我有一个带有包含表单的模板的组件。
我的组件.html:
<div>
<form name="myForm">
<!-- more html code -->
</form>
</div>
如何在组件控制器中访问 myForm?目前我正在注入 $scope 以从中获取它。或者这是获取表格的唯一方法?
编辑:添加了一些代码以更好地在 javascript 中说明
angular.module('example')
.component('myComponent', {
templateUrl: 'mycomponent.html',
controller: function($scope) {
$scope.myForm // This works
this.myForm // undefined, can I access it through the component scope instead of $scope somehow?
}
});