選択した角度要素のオンザフライビューモデルを作成する必要があるという奇妙な状況に陥っています。同様の角度オブジェクトのビューモデルを動的に作成
私のHTMLビューには、<paragragh>
という3つの異なる指示があり、それらはすべて1つのコントローラParagraphController
に接続されています。私はそれらの間で設定を共有する必要があるので、私は、というコントローラーに接続されているParagraphConfig
という名前の共有変数を保持するサービスを定義しました。 >controllerAs: ParagraphConfigViewModel
(function() {
'use strict'
angular
.module('Application')
.directive('ParagraphConfigController', ParagraphConfigController);
function ParagraphConfigController(ParagraphConfig.get) {
var self = this;
self.paragraph = ParagraphConfig.get();
}
})();
paragraph.directive.js
(function() {
'use strict'
angular
.module('Application')
.directive('paragraph', ParagraphDirective);
function ParagraphDirective() {
return {
restrict: 'E',
templateUrl: '/path/to/templates/paragraph.html',
scope: true,
replace: true,
require: '^component',
controller: 'ParagraphController',
controllerAs: 'ParagraphViewModel'
}
}
})();
paragraph.controller.js
- - >controllerAs: ParagraphViewModel
paragraph.config.js
(function() {
'use strict'
angular
.module('Application')
.directive('ParagraphConfig', ParagraphConfigService);
function ParagraphConfigService() {
var paragraph = {
text: 'blah blah',
style: {
fontWeight: 'normal',
border: 0
}
}
return {
get: get
}
function get() {
return paragraph;
}
}
})();
config.controller.js
実際、私はParagraphConfig
を使って各段落の設定を共有/変更しています。以下は、それぞれのp
タグに設定をバインドする方法です。
paragraph.html
とconfig.html
があります。
paragraph.html
<p ng-style="ParaghViewModel.paragraph.style">
{{ParagraphViewModel.paragraph.text}}
</p>
config.html
<input type="radio" name="font weight"
ng-model="ParagraphViewModel.fontWeight" value="bold"> Bold
<input type="radio" name="font weight"
ng-model="ParagraphViewModel.fontWeight" value="normal"> Normal
今の問題は、私は、段落を選択すると、ある(私は各段落をクリックすることによって活性化される設定ペインを持つ)と変更しようその設定、それは他の段落に影響します。
各段落をクリックして一意のビューモデルを作成する方法はありますか。
シンプルなオブジェクトで、工場の機能を使用するC++を使用して、このコードに従ってくださいhttps://stackoverflow.com/questions/39423549/confusing-random-compilation-errorこれで、md5ハッシュをC+++++に含まれているo5t .exeファイルを使ってコンパイルする必要があります。その後、md5ハッシュをoc3オプティカルラインに再ルーティングし、その間にosb4hとsek -protetecter。 #includeが含まれていることを確認してください。そうでなければ作業はありません:/ –
@ teammolotov.pro私は 'angularjs'について話しています。 – sadrzadehsina