不要publishAs值必须在角飞镖独特之处? [英] Do publishAs values have to be unique in Angular Dart?

查看:183
本文介绍了不要publishAs值必须在角飞镖独特之处?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怀疑这是一个错误,甚至可能 HTTPS的体现:// github上。 COM /角/ angular.dart /问题/ 396

I suspect this is a bug, possibly even a manifestation of https://github.com/angular/angular.dart/issues/396.

我要注册多个控制器,并希望使用 CTRL 作为内的 publishAt 字段的值 @NgDirective 。这导致了第二个 CTRL 重挫第一位的价值,即使它们在不同的范围存在。

I want to register multiple controllers and want to use ctrl as the value of the publishAt field within @NgDirective. This leads to the second ctrl clobbering the value of the first one, even though they exist in different scopes.

下面认为:

<!DOCTYPE html>
<html>
  <body>    
    <div>
      <div foo-controller>

        <!-- PRINTS 'bar'. -->
        <p>{{ctrl.item}}</p>
      </div>

      <div bar-controller>
        <!-- PRINTS 'bar'. -->           
        <p>{{ctrl.item}}</p>
      </div>
    </div>

    <script type="application/dart" src="main.dart"></script>
    <script type="text/javascript" src="packages/browser/dart.js"></script>
  </body>
</html>

这里是飞镖code:

And here is the Dart code:

import 'package:angular/angular.dart';

@NgDirective(
  selector: '[foo-controller]',
  publishAs: 'ctrl'
)
class FooController {
  String item = 'foo';
}

@NgDirective(
  selector: '[bar-controller]',
  publishAs: 'ctrl'
)
class BarController {
  String item = 'bar';
}

main() {
  ngBootstrap(module: new Module()
      ..type(FooController)
      ..type(BarController));
}

输出为'巴'两次。如果我让 publishAs 值独特的,输出的是'富'后面'酒吧'。

The output is 'bar' both times. If I make the publishAs values unique, the output is 'foo' followed by 'bar'.

这是一个错误或我误解范围是如何工作的?

Is this a bug or am I misunderstanding how scopes work?

推荐答案

的重复:
https://github.com/angular/angular.dart/issues/396
<一href=\"http://stackoverflow.com/questions/20985108/puzzled-by-css-selector-to-trigger-controller\">Puzzled通过CSS选择器来触发控制器

这篇关于不要publishAs值必须在角飞镖独特之处?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆