2016-06-29 10 views
1

angular Controller kann nicht mit index.html das Projekt wird mit http-Server mit node.js installiert ausgeführt werden.kann nicht ausgeführt werden angularjs file controller Fehler

classifieds.js

 `(function() { 
      "use strict"; 
      angular 
      .module("ngClassifieds") 
      .controller("ClassifiedsCtrl", ['$scope', function($scope) { 
      $scope.name ={text: 'Asif'}; 
      }; 
       }]();` 

index.html

  `<!DOCTYPE html> 
       <html> 
      <head> 
       <title>ngClassifieds</title> 
      </head> 
     <body ng-app="ngClassfieds" ng-controller="ClassifiedsCtrl"> 

     <input type="text" placeholder="Whats your name" ng-model="name" > 
     <h1>{{greeting.text}}</h1> 
     <script src="node_modules/angular/angular.min.js"> </script> 
     <script src="scripts/app.js"></script> 
     <script src="components/classifieds.js"></script> 
     </body> 
     </html>` 
+0

aussehen lassen sollte eine Verwendung 'ngClassifieds' -Modul, eckig. Modul ("ngClassifieds", []) .. – Ajay

Antwort

0

Ihre classified.js Datei wie diese

angular.module("ngClassifieds",[]) 
    //you should pass an empty array in every module NOTE:inside the array it can the injected field 

    (function() { 
       "use strict"; 

       .controller("ClassifiedsCtrl", ['$scope', function($scope) { 
       $scope.name ={text: 'Asif'}; 
       }; 
        }](); 
Verwandte Themen