我想使用这个 Plunk 的代码形式。
它有一个指令:
myApp.directive('fileModel', ['$parse', function ($parse) {
和服务
myApp.service('fileUpload', ['$http', function ($http) {
并且该示例因此注入到控制器中:
myApp.controller('myCtrl', ['$scope', 'fileUpload', function($scope, fileUpload){
我有这个:
angular
.module('Dashboard')
.controller('DashboardController', DashboardController);
和
function DashboardController($rootScope, $scope, $http,
$interval, $state, $location)
{
但是我不知道如何将文件上传注入我的控制器:-(
试试这样。 我认为您的问题是模块名称.我在同一模块中定义fileUpload
服务以进行DashboardController
var myApp = angular.module("yourAppName",[]);
myApp.directive('fileModel', ['$parse', function ($parse) {
...
myApp.service('fileUpload', ['$http', function ($http) {
...
myApp.controller('DashboardController', DashboardController);
function DashboardController($rootScope, $scope, $http,
$interval, $state, $location,fileUpload)
{