Cleanup error: [$ injector: modulerr]

Forgive me. I have seen many themes with the same name, but they didn't help me. Probably everyone has a specific code.

    var app = angular.module('iop', []);
    // Set up the service factory to create our Items interface to the

    var obj={name:'sasha'}
    var obj2= {status: 'run'}

    app.factory('dataService', function(){
        return{

                text: ' js-frame?',
                author: 'Vani'
            }           
    })

    app.controller('QuestionController',['obj','$scope','obj2','dataService'
        function QuestionController(object,$scopes,object2,dataService){

            $scopes.data= object.name

         $scopes.text= object2.status +dataService.text

        }]
    )


<div ng-controller = "QuestionController">
Status :<p> {{data}}</p>
app: <p>{{text}}</p>
</div>

      

Error: Uncaught SyntaxError: Unexpected token function index.html: 46 Cleanup error: [$ injector: modulerr]

+3


source to share


2 answers


These two variables:

var obj={name:'sasha'}
var obj2= {status: 'run'}

      

There should be module values:

app.value("name", "sasha");
app.value("status", "run");

      

They can then be injected into your controller like this:

 app.controller('QuestionController',['name','$scope','status','dataService',
            function QuestionController(name,$scope,status,dataService){

      



Also this line:

 app.controller('QuestionController',['obj','$scope','obj2','dataService'
        function QuestionController(object,$scope,object2,dataService){

      

Missing comma after dataService

app.controller('QuestionController',['obj','$scope','obj2','dataService',
         function QuestionController(object,$scope,object2,dataService){

      

You also misspelled $ scope multiple times. (Have $ scopes )

We hope these fixes help.

+3


source


  • obj and obj2 are simple objects, you haven't registered them as angular service \ provider \ constant \ anything, so they cannot be nested in injection.

  • Don't use the mini angular version, you will get error messages this way.



+3


source







All Articles