Python を学ぶことで、角ばったことをすべて忘れてしまいました。それが私の話であり、私はそれに固執しています。似たような質問がどこにも見つからないので、Google のスキルを忘れてしまいました。最も近いのはHow to append to a json object in angular jsかもしれませんが、それも機能しませんでした。
タイトルと説明の 2 つの入力フィールドが 10 セットあります。それらを子として配列に追加したいので、json には 10 個のプロパティがあり、各プロパティには 2 つの子プロパティがあります。私はプッシュ、連結、さらには昔ながらの += を絶望的に試みましたが、何も機能していません。私は明らかなことを完全に見逃しているに違いありません。
数字は (1 から 10 まで) 変化しますが、各行は次のようになります。
<label class="sr-only" for="shorttitle1">short title</label>
<input type="text" class="form-control" ng-click="addIdea()" ng-model="idea1.title" placeholder="title">
<label class="sr-only" for="description1">description</label>
<input type="text" class="form-control" ng-click="addIdea()" ng-model="idea1.description" placeholder="description">
私のコントローラーで、上記のリンクに基づいて試したバージョンは次のとおりです。これは、concat または push よりもうまく機能していません。
$scope.ideas = [
{idea : $scope.idea1.title, $scope.idea1.description},
{idea : $scope.idea2.title, $scope.idea2.description},
{idea : $scope.idea3.title, $scope.idea3.description}
];
ドットの予期しないトークンのエラーが発生し続けます ($scope-dot-idea1 のドットなど)。テストとして単純なテキストを入力すると、閉じ括弧で予期しないトークン エラーが発生します。
コントローラーが注意を払うかどうかを確認するためだけに、watchCollection を試してみましたが、それからは何も得られません。idea1、$scope.idea1、$scope.idea1.title の順に見てみましたが、watchCollection はそのままです。
これは、大まかに次のように仕上げたいものです。
$scope.ideas = [
{
type : 'title goes here',
description : 'description goes here'
},{
type : 'title goes here',
description : 'description goes here'
},{
type : 'title goes here',
description : 'description goes here'
}
];
私は本当に明白なことを確認しました.ng-appはng-controllerと同じレベルではありません.正しいコントローラーを呼び出しています.奇抜なスペルミスはありません.
ヘルプ?