Javascript 如何将$scope传递给解析承诺函数
问题是我无法在此处注入$scope: testCtrl.loaddata=函数($scope){Javascript 如何将$scope传递给解析承诺函数,javascript,angularjs,promise,Javascript,Angularjs,Promise,问题是我无法在此处注入$scope: testCtrl.loaddata=函数($scope){ 如何在解析函数中获取$scope?为什么要在解析中使用$scope?var promise=angularFire(“”,$scope,'items',[]);它有$scope作为参数传递。$rootScope在这里工作,但我不想使用全局范围 var testApp = angular.module('testApp', ['firebase']) .config(['$routeProvider'
如何在解析函数中获取$scope?为什么要在解析中使用$scope?var promise=angularFire(“”,$scope,'items',[]);它有$scope作为参数传递。$rootScope在这里工作,但我不想使用全局范围
var testApp = angular.module('testApp', ['firebase'])
.config(['$routeProvider','$locationProvider',function ($routeProvider,$locationProvider) {
$routeProvider
.when('/test', {
templateUrl: '/views/test.html',
controller: 'TestCtrl',
resolve:
{
loaddata: testCtrl.loaddata
}
});
}]);
var testCtrl = testApp.controller('TestCtrl',['$scope', function ($scope) {
}]);
testCtrl.loaddata = function($scope) {
return promise;
}