2021年1月16日星期六

AngularJS Project doesn't work properly with seperate controller js file

I am new in AngularJS and i tried to seperate the controller javascript file and linked it with script in html file.Eventhough i tried dot notation,the variable initialized inside the controller doesn't appear in view.It works when the controller code is in the same html file.How can i fix that problem?

index.html

<body>      <div ng-app="myApp" ng-controller="myController">        <h1></h1>        <script src="js/app.js"></script>        <script src="js/controller.js"></script>      </div>    </body>   

controller.js

myApp.controller("myController",function($scope,$http){          $scope.object={variable:"test"};  });  

app.js

var myApp=angular.module("myApp",[]);  
https://stackoverflow.com/questions/65756645/angularjs-project-doesnt-work-properly-with-seperate-controller-js-file January 17, 2021 at 10:06AM

没有评论:

发表评论