AngularDart弹出组件

时间:2017-07-14 08:41:26

标签: dart angular-dart angular-components dart-html dart-webui

enter image description here enter image description here我应该如何在AngularDart中的用户个人资料图片上实现angular_components的弹出窗口。

https://dart-lang.github.io/angular_components_example/#Popups 这个示例链接帮助我了解AngularDart组件及其实现,但我仍无法在用户配置文件映像上实现它。所以任何人都可以帮助我知道我该怎么做

提前谢谢。

app_header.dart

@Component(selector: 'app-header',
templateUrl: 'app_header.html',
styleUrls: const ['app_header.css'],
directives: const [
  MaterialButtonComponent,
  MaterialPopupComponent,
  PopupSourceDirective,
  DefaultPopupSizeProvider,
],
providers: const [
  popupBindings,
  DefaultPopupSizeProvider,
],)


class AppHeader {
final FirebaseService fbService; 
bool headerFooterPopupVisible = false; 

String get tooltipMsg => 'All the best messages appear in tooltips.'; 
String get longString => 'Learn more about web development with AngularDart'
  'here. You will find tutorials to get you started.';

AppHeader(FirebaseService this.fbService);
}

@Injectable()
PopupSizeProvider createPopupSizeProvider() {
return const PercentagePopupSizeProvider();
}
@Directive(selector: '[defaultPopupSizeProvider]', providers: const [
const Provider(PopupSizeProvider, useFactory: createPopupSizeProvider)
])
class DefaultPopupSizeProvider {}

app_header.html

<header class="navbar-dark bg-primary layout horizontal center justified">
<div class="horiz">
<div id="chat-bubble" class="icon"></div>
<a class="navbar-brand">Dart Chat</a>
</div>

<div class="horiz">
<div id="sign-in" *ngIf="fbService.user == null" class="horiz">
  <div id="google-icon" class="icon"></div>
  <button class="btn btn-outline-secondary btn-sm" 
(click)="fbService.signIn()">Google Sign In</button>
</div>

<div id="sign-out" *ngIf="fbService.user != null" class="horiz">
  <div id="user-name">{{fbService.user?.displayName}}</div>
  <img class="icon" [src]="fbService.user?.photoURL">

  <button class="btn btn-outline-secondary btn-sm" (click)="fbService.signOut()">Sign Out</button>

  <material-button class="blue"
                   raised
                   popupSource
                   #headerExampleSource="popupSource"
                   (trigger)="headerFooterPopupVisible = !headerFooterPopupVisible">
    {{headerFooterPopupVisible ? 'Close' : 'Open'}} Custom Popup
  </material-button>
  <material-popup defaultPopupSizeProvider
                  enforceSpaceConstraints
                  [source]="headerExampleSource"
                  [(visible)]="headerFooterPopupVisible">
    <div header class="custom-header">
      This is a Header demo
    </div>
    <div class="custom-body">
      Hello, Hello, Hello. This is a tall bit of content that needs a scroll
      bar because the content is so long.
    </div>
    <div footer class="custom-footer">
      This is a Footer demo
    </div>
  </material-popup>

</div>

如果我使用以下代码。

错误:dart_chat_ng2_fb3上的DirectiveProcessor | lib / views / app_header / app_header.dart]: 错误:模板解析错误:AppHeader的第25行第7行:ParseErrorLevel.FA TAL:Void元素没有结束标记&#34; img&#34; ^^^^^^ [来自dart_chat_ng2_fb3上的TemplateCompiler的错误| lib / views / app_component / app_co mponent.ng_meta.json]: 找不到名称的指令/管道条目:AppHeader 。请注意,Dart变压器的支持有限

<img [src]="fbService.user?.photoURL" class="blue"
                   raised
                   popupSource
                   #headerExampleSource="popupSource"
                   (trigger)="headerFooterPopupVisible = !headerFooterPopupVisible">
    {{headerFooterPopupVisible ? 'Close' : 'Open'}} Custom Popup
  </img>
  <material-popup defaultPopupSizeProvider
                  enforceSpaceConstraints
                  [source]="headerExampleSource"
                  [(visible)]="headerFooterPopupVisible">
    <div header class="custom-header">
      This is a Header demo
    </div>
    <div class="custom-body">
      Hello, Hello, Hello. This is a tall bit of content that needs a scroll
      bar because the content is so long.
    </div>
    <div footer class="custom-footer">
      This is a Footer demo
    </div>
  </material-popup>

如果我只是改变&#34;材料按钮&#34;标记为&#34;按钮&#34;弹出窗口没有显示

1 个答案:

答案 0 :(得分:0)

如果您阅读此部分,则错误来自模板: Void elements do not have end tags "img"它会指出您的问题 - 永远不应该有</img>代码,因为<img>永远不能包含内容。

一些细节:https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img