0
私は助けが必要です。私は価値ROMのactoryメソッドを返そうとしていますが、いくつかの予想されるエラーを得ることはできませんでした。私は以下のコードを説明しています。Angular.jsを使用してファクトリメソッドから値を返せません
compliance.factory('showNabh',function($window,$timeout){
var defaultView=function(){
return true;
}
var auditView=function(){
return false;
}
})
compliance.controller('NABHParentController',function($scope,$http,$state,$window,$location,$filter,showNabh){
$scope.showNabh=showNabh.defaultView();
})
ここで私は以下のエラーが発生しています。
Error: [$injector:undef] http://errors.angularjs.org/1.4.6/$injector/undef?p0=showNabh
at angularjs.js:6
at Object.$get (angularjs.js:37)
at Object.e [as invoke] (angularjs.js:39)
at angularjs.js:41
at d (angularjs.js:38)
at e (angularjs.js:39)
at Object.instantiate (angularjs.js:39)
at angularjs.js:80
at q (angularuirouter.js:7)
at A (angularuirouter.js:7)
は、ここで私は私がdefaultView
関数を呼び出しますときに私はtrue
値を取得し、私はauditView
慰めを呼ぶ場合、私は偽の値を取得します必要があります。実際には私は$scope.showNabh
変数グローバルにする必要がありますので、任意のコントローラでこの変数に任意の値を割り当てることができます。助けてください。
はい、でもエラーが発生します。 – subhra
ファクトリは関数のオブジェクトを返す必要があります –