如何在Angular 2及更高版本中实现模态对话框(How to implement Modal Dialog in Angular 2 and above)
我是一个角色的新手。
我已经使用包ng2-bootstrap使用了bootstrap模式。
我的视图文件是
<div bsModal #lgModal="bs-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true"> <div class="modal-dialog modal-lg"> <div class="modal-content"> <div class="modal-header"> <h4 class="modal-title pull-left">Area Master</h4> <button type="button" class="close pull-right" (click)="lgModal.hide();" aria-label="Close"> <span aria-hidden="true">×</span> </button> </div> <div class="modal-body"> Modal Content here... </div> <div class="modal-footer"> <button type="submit" class="btn btn-primary">Add</button> </div> </div> </div> </div>
我需要知道如何从组件(类型脚本文件)显示/隐藏此模式。
类型脚本文件是
import { Component, OnInit, ViewChild, ElementRef } from '@angular/core'; import { Router } from '@angular/router'; import { FormGroup, Validators, FormBuilder, FormControl } from '@angular/forms'; import { Area } from './area'; import { AreaService } from './area.service'; @Component({ moduleId: module.id, selector: 'my-areas', templateUrl: './areas.component.html', styleUrls: ['./areas.component.css'] }) export class AreasComponent implements OnInit { area_form: FormGroup; new_area: Area; areas: Area[]; @ViewChild('lgModal') lgModal:ElementRef; constructor( private areaService: AreaService, private router: Router, private form_builder: FormBuilder) { } getAreas(): void { this.areaService .getAreas() .then(areas => this.areas = areas); } submit(area: Area): void { console.log(area); this.areaService.create(area) .then(area => { this.areas.push(area) }) } ngOnInit(): void { this.getAreas(); this.lgModal.show(); this.area_form = this.form_builder.group({ name: ['', Validators.required], pincode: ['', Validators.required], status: ['Active'], type: ['Busines Service Area'] }) } }
I am a newbie to angular.
I have used bootstrap modal using the package ng2-bootstrap.
My View file is
<div bsModal #lgModal="bs-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true"> <div class="modal-dialog modal-lg"> <div class="modal-content"> <div class="modal-header"> <h4 class="modal-title pull-left">Area Master</h4> <button type="button" class="close pull-right" (click)="lgModal.hide();" aria-label="Close"> <span aria-hidden="true">×</span> </button> </div> <div class="modal-body"> Modal Content here... </div> <div class="modal-footer"> <button type="submit" class="btn btn-primary">Add</button> </div> </div> </div> </div>
I need to know how to show/hide this modal from the component (type script file).
Type script file is
import { Component, OnInit, ViewChild, ElementRef } from '@angular/core'; import { Router } from '@angular/router'; import { FormGroup, Validators, FormBuilder, FormControl } from '@angular/forms'; import { Area } from './area'; import { AreaService } from './area.service'; @Component({ moduleId: module.id, selector: 'my-areas', templateUrl: './areas.component.html', styleUrls: ['./areas.component.css'] }) export class AreasComponent implements OnInit { area_form: FormGroup; new_area: Area; areas: Area[]; @ViewChild('lgModal') lgModal:ElementRef; constructor( private areaService: AreaService, private router: Router, private form_builder: FormBuilder) { } getAreas(): void { this.areaService .getAreas() .then(areas => this.areas = areas); } submit(area: Area): void { console.log(area); this.areaService.create(area) .then(area => { this.areas.push(area) }) } ngOnInit(): void { this.getAreas(); this.lgModal.show(); this.area_form = this.form_builder.group({ name: ['', Validators.required], pincode: ['', Validators.required], status: ['Active'], type: ['Busines Service Area'] }) } }
原文:https://stackoverflow.com/questions/42735858
更新时间:2022-05-18 09:05
最满意答案
我发现了这个问题,显然我犯了新的错误,在我重新启动应用程序进行读/写而不是只读之后不更新我的所有令牌。
I found the issue, apparently I made the rookie mistake of not updating all my tokens after I regenerated the application to be read/write instead of just read.
相关问答
更多-
那么这是一个非常普遍的问题,所以我给你一个通用的答案。 使用Twitter API提取标有@YourCompanyName或#YourCompany的数据。 https://dev.twitter.com/docs/api 很直接。 Well this is a very general question so I'm providing you with a general answer. Use the Twitter API to pull data that is marked with @Your ...
-
“作者”始终是认证用户。 从状态/更新的Twitter API文档 : 更新身份验证用户的当前状态,也称为推特。 要回答有关使用其他用户的用户名/密码进行身份验证的其他问题,可能需要获得Twitter的许可。 您还需要使用OAuth。 查看Twitter API xAuth文档 。 The "author" is always going to be the authenticating user. From the Twitter API documentation for statuses/update ...
-
Twitter4j - 只提供来自用户的几条推文--Android(Twitter4j--only bringing up few tweets from user - Android)[2022-11-23]
您应该使用分页,看看: 使用时间轴,页面或Twitter4j代码示例 - 分页或Twitter4j分页javadoc 编辑你的情况我会用这个: 以下是我如何设法获得100条推文(我正在向SQLite DB发送推文,但在你的情况下分页是相同的) void fetch_timeline(){ SQLiteDatabase db = this.getWritableDatabase(); ContentValues values = new ContentValues(); ... -
我之前尝试在多个Twitter帐户上发布时遇到了同样的问题,我已经解决了这个问题: 首先:您需要为您管理的每个Twitter帐户创建一个Twitter应用程序 ,并从每个应用程序中获取这些数据: API密钥(消费者密钥) API秘密(消费者秘密) 访问令牌 访问令牌密钥 以下是您将如何使用它们: // set twitter app data of the twitter account you are going to publish to.. if (some_condition) { $co ...
-
我正在为您发布我的实时代码。希望它适合您。 SearchTerm是search.Below方法的关键字,它将在String中返回一个json响应。 如果你想要gson序列化类。 我会为你提供 ProgressDialog pd; new DownloadTwitterTask().execute(keyword); private class DownloadTwitterTask extends AsyncTask
{ ... -
刷新Twitter推文时出错(Error Refreshing Twitter Tweets)[2021-09-28]
在你的-[AppDelegate didFinishLaunchingWithOptions:] : #ifdef DEBUG NSSetUncaughtExceptionHandler(&uncaughtExceptionHandler); #endif 在文件底部的AppDelegate中,所有方法的下方: #ifdef DEBUG void uncaughtExceptionHandler(NSException *ex) { NSLog(@"CRASH :\n %@", ex.re ... -
我发现了这个问题,显然我犯了新的错误,在我重新启动应用程序进行读/写而不是只读之后不更新我的所有令牌。 I found the issue, apparently I made the rookie mistake of not updating all my tokens after I regenerated the application to be read/write instead of just read.
-
twitteR软件包正在被弃用 。 你应该使用rtweet代替。 您可以从CRAN下载rtweet ,但目前我建议从Github下载开发版本。 dev版本默认会返回tweets的全文。 它还会返回转发或引用状态的完整原始文本的文本。 要从Github安装最新版本的rtweet,请使用devtools软件包。 ## install newest version of rtweet if (!requireNamespace("devtools", quietly = TRUE)) { install.pa ...
-
从文档: $twitter = new Zend_Service_Twitter(array( 'username' => 'johndoe', 'accessToken' => $token )); $response = $twitter->status->update('My Great Tweet'); http://framework.zend.com/manual/en/zend.service.twitter.html From the doc ...
-
twitter API搜索推文(twitter API search for tweets)[2022-03-15]
根据Twitter Search API文档,您无法进行所需的查询: https : //dev.twitter.com/rest/public/search Twitter Search API会搜索过去7天内发布的最新推文。 超过过去7天,您想要实现的目标只能通过在Twitter上手动搜索帐户来完成。 一种选择是使用https://webrecorder.io/ 滚动到您要记录或尝试捕获整个Feed的时间。 请注意自动滚动选项。 According to the The Twitter Search A ...