How Do I Inject This Directive into My Angularjs Controller?
I Want to Use the Code Form This Plunk. It Has a Directive: myApp. Directive('Filemodel', ['$Parse', Function ($Parse) { and a Service myApp...
I want to use the code form this Plunk.
It has a directive:
myApp.directive('fileModel', ['$parse', function ($parse) {
and a service
myApp.service('fileUpload', ['$http', function ($http) {
and the example injects into the controller thusly:
myApp.controller('myCtrl', ['$scope', 'fileUpload', function($scope, fileUpload){
I have this:
angular
.module('Dashboard')
.controller('DashboardController', DashboardController);
and
function DashboardController($rootScope, $scope, $http,
$interval, $state, $location)
{
But I can't figure out how to inject the file upload into my controller :-(
1 Answer
Try like this. i think your problem is for module name.i define fileUpload service in same module for 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)
{