정말 간단합니다 (아래 코드). 두 html 페이지, test.htm 및 ang.htm 있습니다. ang.htm 페이지에 대한 하나의 하이퍼 링크로 test.htm을 시작합니다. ang.htm에는 Hello World를 수행하는 간단한 컨트롤러가 하나있는 각도 j가 포함되어 있습니다. 하이퍼 링크를 클릭하여 ang.htm으로 이동합니다. 각도 코드를 실행하려면 ang.htm 페이지를 새로 고쳐야합니다. 왜 그런가요?AngularJS는 새로 고침하지 않으면 컨트롤러를 실행하지 않습니다.
test.htm을
<html>
<body>
<a href="http://localhost/ang.htm">Click</a>
</body>
</html>
귀하의 코드가 작동ang.htm
<html>
<body ng-app="testApp" ng-controller="testController">
{{hello}}
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.5/angular.min.js"></script>
<script>
angular.module("testApp", []);
angular.module("testApp").controller("testController", function($scope)
{
$scope.hello = "Hello world";
});
</script>
</body>
</html>
예, 작동합니다. btw, 머리를 더 잘 옮길 스크립트 –