私はangle/js開発でかなり新しいので、これでスタックしました。2番目のng-controllerを追加する
ng-controller = "HeaderController"をHTMLコードに追加すると、Angularが読み込まれません。これを削除しても問題ありません。なぜそれが起こったのですか?任意のヘルプと悪い英語のため申し訳ありませんしてくれてありがとう:)
コード:
(function() {
\t var app = angular.module ('FunStuff',[]);
\t app.controller ('TextController',['$scope',function($scope){
\t \t $scope.stuff = [];
\t \t $scope.add = function(){
\t \t \t \t $scope.stuff.push ($scope.name);
\t \t }
\t }]);
\t app.controller ('HeaderController'['$scope',function($scope){
\t \t $scope.textClass = '';
\t \t $scope.changeClrClss = function(name){
\t \t \t $scope.ClrClss = name;
\t \t }
\t }]);
})();
<!DOCTYPE html>
<html ng-app ="FunStuff">
<head>
\t <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.32/angular.min.js"></script>
\t <link rel="stylesheet" type="text/css" href="style.css">
\t <title>LEARN JS</title>
\t <meta charset="utf-8">
</head>
<body >
\t <header ng-class = "ColorClass" ng-controller="HeaderController">
\t \t <h1>$~/Path_To_Js/</h1>
\t \t <button class="changeColorBtn" ng-click="changeColorClass('white')">
\t \t \t ChangeColorButton
\t \t </button>
\t </header>
\t <div class="wrapper" >
\t \t <article ng-controller = "TextController">
\t \t \t <p>There will be some information</p>
\t \t \t <form ng-submit="add()">
\t \t \t \t <input ng-model="name"><button>Add</button>
\t \t \t </form>
\t \t \t <ul class="buttons" ng-repeat= "n in stuff track by $index">
\t \t \t \t <li>{{n}}</li>
\t \t \t </ul>
\t \t </article>
\t </div>
\t <script type="text/javascript" src="index.js"></script>
</body>
</html>