未知提供者錯誤: [$ injector:unpr] http://errors.angularjs.org/1.4.3/ $ injector/unpr? P0 = postbuttonsProvider%20%3 C-%20postbuttons%20%3 C-%20RandomBusinessCtrl
這裏是我的代碼:該指令的定義如下:
angular.module('home', ['ngAnimate', 'ui.bootstrap','ngDialog'])
.directive("postbutton", function(){
return {
restrict: "E",
bindToController: true,
template: "<button>Post review</button>"
}
})
.controller('RandomBusinessCtrl',
['$scope','postbutton','pickRandomBusinesses','BusinessViewModel','config',
function ($scope,postbutton,pickRandomBusinesses,BusinessViewModel,config) {
});
我的HTML是:
<div ng-controller="RandomBusinessCtrl">
<span class="badge pull-right" style="background-color:#CB525B;" >
<postbuttons></postbuttons>
<!-- <button type="button" value="post_business" style="background-color:#CB525B; height:15px;border:0px;`" ng-click="postReview(random_business.id,user_id,rate,price,date_created,details)">Post review</button> -->
</span>
請添加一些代碼或提供plunker – varit05
你不能注入指令的控制器內......從RandomBusinessCtrl –