Javascript AngularJS将函数添加到范围
嗨,我有个恼人的问题。我正在尝试向$scope添加两个方法。我正在这样做:Javascript AngularJS将函数添加到范围,javascript,Javascript,嗨,我有个恼人的问题。我正在尝试向$scope添加两个方法。我正在这样做: function typeCtrl ($scope, $timeout) { $scope.addType = function(){ requestHelper.addType(); }; $scope.removeType = function(number){ alert("asdasdsad"); requestHelper.removeType(numbe
function typeCtrl ($scope, $timeout) {
$scope.addType = function(){
requestHelper.addType();
};
$scope.removeType = function(number){
alert("asdasdsad");
requestHelper.removeType(number);
};
};
我试着这样称呼它:
<button id="addType" class="btn btn-primary glyphicon glyphicon-plus" ng-click="addType()"></button>
<button id="removeRequest" class="btn btn-danger glyphicon glyphicon-minus" ng-click="removeType(1)"></button>
方法addType()工作正常,但看不到removeType()方法。你能告诉我我做错了什么吗。感谢您的回复。这可能是因为第一个按钮上没有结束括号吗?您能生成一个JSFIDLE来隔离这个问题吗。马上我看不出你做得不对。