首页 \ 问答 \ 如何在angular2中更改按钮文本并禁用点击事件按钮(How to change button text and disable button on click event in angular2)

如何在angular2中更改按钮文本并禁用点击事件按钮(How to change button text and disable button on click event in angular2)

如何在angular2中单击该按钮时如何更改<button>的文本?

例如,将按钮文本从“保存”更改为“保存...”,然后将其设置为禁用。

我知道如何在AngularJS,jQuery和普通的JS中做到这一点,并且我对Angular2中如何实现这一点有一些想法,但是我想确保在涉及到的时候我不会以某种过时或复杂的方式来做到这一点Angular2。


How do you change the text of a <button> when that button is clicked in angular2?

For example, changing the button text from "Save" to "Saving..." and then also set it to be disabled.

I know how to do this in AngularJS, jQuery, and plain JS, and I have some ideas on how to do this in Angular2, but I wanted to make sure I'm not doing it in some outdated or convoluted way when it comes to Angular2.


原文:https://stackoverflow.com/questions/41489355
更新时间:2022-03-05 15:03

最满意答案

在第一段QVBoxLayout vbox; 在堆栈上创建。
一旦方法执行完成,它就会被销毁。

在第二个段中, QVBoxLayout* box在堆中创建,并且在窗口小部件处于活动状态之前不会销毁它。

Qt布局在显示或调整窗口小部件时完成它们的工作,这就是为什么它们应该存在直到窗口小部件存在。

更多信息:
堆栈和堆
块和局部变量


In the first segment QVBoxLayout vbox; is created on the stack.
It is destroyed as soon as the method execution if finished.

In the second segment QVBoxLayout* box is created in a heap and it's not destroyed until the widget is alive.

Layouts in Qt do their job when a widget is shown or resized that's why they should exist until a widget exists.

More information:
The stack and the heap
Blocks and local variables

相关问答

更多
  • 这是一个缓冲问题。 通常,IO是行缓冲的(也就是说,除非您明确地清空缓冲区,否则输出实际上不会显示在屏幕上,除非您打印新行或超过缓冲区大小)。 在ghci中不是,所以这个问题没有出现。 在调用getLine之前,您可以使用hFlush stdout来刷新标准输出,从而将输出打印到屏幕上。 或者,您可以使用hSetBuffering NoBuffering完全禁用缓冲,从而消除对hFlush的需求。 尽管如此,这可能会对IO性能产生负面影响。 It's a buffering issue. Usually I ...
  • 在第一段QVBoxLayout vbox; 在堆栈上创建。 一旦方法执行完成,它就会被销毁。 在第二个段中, QVBoxLayout* box在堆中创建,并且在窗口小部件处于活动状态之前不会销毁它。 Qt布局在显示或调整窗口小部件时完成它们的工作,这就是为什么它们应该存在直到窗口小部件存在。 更多信息: 堆栈和堆 块和局部变量 In the first segment QVBoxLayout vbox; is created on the stack. It is destroyed as soon as ...
  • 在第一个示例中,您使用引用来获取数组,然后进行修改。 只有一个数组,您可以更改它。 在第二个示例中,您使用引用来获取数组,然后将数组的内容复制到第二个数组中 ,然后修改第二个数组。 有两个数组,你永远不会改变原来的数组。 In the first example, you use the reference to get the array and then you modify that. There is only one array and you change it. In the second e ...
  • 从Java 7开始,您可以在单个catch块中捕获多个异常类型 。 代码看起来像这样: String str = null; try { ... str = "condition2"; } catch (ApplicationException|IllegalStateException|Exception ex) { str = "condition3"; } BTW:您发布的代码以及我的Java 7代码都可以简化为catch (Exception e) ,因为Exceptio ...
  • PhotoViewModel类包含两个名为Value属性,其中一个PropertyViewModel在PropertyViewModel定义,类型为object 。 另一个是在PhotoViewModel定义的,类型为PhotoValueViewModel (这基本上隐藏了其他属性,您应该从Visual Studio收到警告)。 在扩展方法中,您引用的是PropertyViewModel.Value ,它是object类型 这是因为在此方法中声明的TDestination类型可从PropertyViewMo ...
  • 当考虑像1:2这样的基本原子向量时, names会附加到每个单独的元素上。 这意味着,如果您不为特定元素names ,则R会使用NA值填充它们。 即: var <- 1:2 names(var) <- c("a","b") var # a b # 1 2 var <- 1:2 names(var) <- c("a") var # a # 1 2 var <- 1:6 names(var) <- c("a","b") var # a b ...
  • 因为在Ruby中:589d62c016bd4d0005bccc15不是有效的符号文字。 如果你有一个从整数或整数本身开始的字符串,转换为符号字面量,它将始终具有以下形式: '23'.to_sym #=> :"23" 23.to_s.to_sym #=> :"23" Because in Ruby :589d62c016bd4d0005bccc15 is not a valid Symbol literal. If you have a string starting from integers or in ...
  • 伟大的问题! 您可以使用描述符轻松完成您所寻求的任务。 描述符是实现描述符协议的 Python对象,通常以__get__()开头。 它们主要存在于不同类中的类属性。 在访问它们时,将__get__()它们的__get__()方法,并传入实例和所有者类。 class DifferentFunc: """Deploys a different function accroding to attribute access I am a descriptor. """ def _ ...
  • Uri类为不同的URI方案使用不同的解析器。 例如,对于http和https URI,它使用HttpStyleUriParser ,而对于ftp URI,它使用FtpStyleUriParser ,依此类推。 具有未知方案的URI由GenericUriParser解析。 您可以使用UriParser.Register方法注册新方案。 UriParser.Register(new HttpStyleParser(), "foobar", 33); The Uri Class uses different p ...
  • Shell使用globbing。 https://en.wikipedia.org/wiki/Glob_(programming) Grep使用正则表达式。 https://en.wikipedia.org/wiki/Regular_expression 它们是两种不同的语言,对于grep, *不是外卡。 它表示前一个字符,重复零次或多次 你要 grep '.*\.xml' 这意味着任何字符 ( . )重复零次或多次( * )后跟一个文字'。' ( \. )xml (出于实际目的,你当然只使用grep . ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。