Я следующее определение контроллера:
angular.module('myapp', [ 'ngRoute' ]).config(function($routeProvider,
$httpProvider) {
[...]
})
.controller('edit', function($scope, $http, $routeParams) {
$scope.projectid = $routeParams.id;
$scope.viewer = "undefined";
$scope.mode = 'nothing';
var projectid = $routeParams.id;
})
.directive('initCesium', function(){
return {
restrict: 'AEC',
link: function(scope, element, attrs) {
if (typeof Cesium !== "undefined") {
startup(Cesium, scope);
} else if (typeof require === "function") {
require(["Cesium", "scope"], startup);
}
}
}
});
Мне нужно отправить запрос веб-службы в функции startup
. Поэтому мне нужно пройти $http
к startup
в 2-х местах:
startup(Cesium, scope);
require(["Cesium", "scope"], startup);
Как я могу это сделать?
И 'startup' is? ... – estus
как насчет' .directive ('initCesium', function ($ http) {... ', а затем' startup (Цезий, область действия, $ http) 'или просто' angular.element (document.body) .injector(). получить ('$ HTTP') ' – webduvet