The controller with the name 'mainController' is not registered

前端 未结 5 1209
死守一世寂寞
死守一世寂寞 2021-01-04 22:47

i have this code in my script.js file

var mainController = function($scope){
  $scope.message = \"Plunker\";
};

and this is my HTML

5条回答
  •  有刺的猬
    2021-01-04 23:26

    You need to register your controller with the main module of your application.

    Try this in your app.js

     var myApp = angular.module('app', []);
     myApp.controller('mainController', function($scope){
        $scope.message = "Plunker";     
     });
    

    and in your html

    
    
        
            
            
            
        
    
        
            

    Hello {{ message }}

提交回复
热议问题