Tushar Rai Tushar Rai - 3 years ago 183
Dart Question

AngularDart Popup Component

enter image description here
enter image description hereHow should I implement Popup of angular_components on user profile image in AngularDart.

https://dart-lang.github.io/angular_components_example/#Popups
This link of examples helped me to know about AngularDart components and about their implementation, but I am still unable to implement it on a user profile image. So can anyone help me to know how should I do that

Thank you in advance.

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>





If I am using the following code.

Error: DirectiveProcessor on dart_chat_ng2_fb3|lib/views/app_header/app_header.dart]:
ERROR: Template parse errors: line 25, column 7 of AppHeader: ParseErrorLevel.FA
TAL: Void elements do not have end tags "img"

^^^^^^
[Error from TemplateCompiler on dart_chat_ng2_fb3|lib/views/app_component/app_co
mponent.ng_meta.json]:
Could not find Directive/Pipe entry for name: AppHeader
. Please be aware that Dart transformers have limited support

<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>


and if I simply change the "material-button" tag to "button" the popup didn't show up

rkj rkj
Answer Source

The error is from the template, if you read this part: Void elements do not have end tags "img" it will point you to the problem - there should never be </img> tag, as the <img> can never contain content.

Some details: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download