私は角度1.6を使用していますが、構成リストと要求日という2つのコンポーネントがあります。角1.6ページ内に複数のカスタムコンポーネントを置くことはできません
コンポーネントがページ上の唯一のコンポーネントであれば正しく動作しますが、ページに複数のコンポーネントを配置すると、2つ目のコンポーネントだけが動作します。したがって、以下のページでは、要求日が正しく機能します。
ページには1つのコンポーネントしか存在できませんか?
<div ng-app="playground" ng-cloak>
<config-list></config-list>
<request-dates></request-dates>
</div>uest-
<script src="~/Scripts/angular.js"></script>
<script src="~/Scripts/app/module.js"></script>
<script src="~/Scripts/app/config-list.component.js"></script>
<script src="~/Scripts/app/request-dates.component.js"></script>
ここにありますmodule.js:
(function() {
"use strict";
angular.module("playground", []);
}());
ここのconfig-list.component.js:
(function(){
var module = angular.module("playground", []);
function controller()
{
var model = this;
};
module.component("configList",
{
templateUrl: "/Scripts/app/config-list.component.html",
controller: controller,
controllerAs: "model"
});
}());
ここのconfig-list.component
はここのメインページです.html:
<p>Hello from configlist</p>
(function() {
var module = angular.module("playground", []);
function controller()
{
var model = this;
}
module.component("requestDates",
{
templateUrl: "/Scripts/app/request-dates.component.html",
controller: controller,
controllerAs: "model"
});
}());
ここでの要求-dates.component.html: - 正しい答えがあったとして、私は誤って上書きした
<p>Hello from requestDates</p>
[更新]ここでの要求-dates.component.js
最初のコンポーネントが表示されなかった理由を説明する、2番目のコンポーネントを含む新しいモジュールを使用して(最初のコンポーネントを消去した)モジュール
外部ファイルにモジュール宣言からブラケットを取り外す(コンマ)みの – sh0ber
可能な重複[AngularJSモジュール宣言のためのベストプラクティス?](のhttp:// stackoverflowの.com/questions/19957280/angularjs-best-practices-for-module-declaration) – sh0ber
いいえsh0ber、これは複製ではありません - ベストプラクティスのリンクは重複した回答ではなく、以下の回答として私は誤ってそれによって既存のモジュールを上書きする)。あなたが誰かの答えを落とす(評判に影響する)前に、あなたはもっと注意するべきです。 –