$scope.testing正在添加为按钮Id正确,但点击按钮不触发警报.
参见示例 – http://plnkr.co/edit/RtidzgiUI7ZAMOTu3XHy?p=preview
CONTROLLER
var app = angular.module('StockCategory',[]); app.controller('stockCategoryController',function($scope) { $scope.testing = 'World'; $scope.saveCategory = function() { alert('hello'); } });
HTML
<div class="stock-categories" ng-app="StockCategory" ng-controller="stockCategoryController"> <button class="btn save-cat" id="{{testing}}" ng-click="saveCategory();">Save</button> </div>