我只是想为另一个问题创建一个最低限度的工作示例,但此后却失败了。我不明白为什么我的控制器类的构造函数没有被执行。有人有主意吗?
class Ctrl {
constructor() {
this.customers = [{
id: 1,
name: "Cust1",
}, {
id: 2,
name: "Cust2",
}, {
id: 3,
name: "Cust3",
}];
alert("Constructor done!");
}
}
angular.module('app', []).controller('Ctrl', Ctrl);
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<body ng-app="app">
<div ng-controller="Ctrl as $ctrl">
<div ng-repeat="customer in $ctrl.customers">
<input type="text" ng-model="customer.name">
</div>
</div>
</body>
答案 0 :(得分:-1)
首先,您必须更新/安装一些最新版本的ES6软件包或模块。please refer this link以获取详细信息。
示例代码
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="button" id="callbtn" value="button For X" >
<input type="button" id="callbtn1" value="button For Y" >