如何在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
最满意答案
在第一段
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 ...
-
最后阻止表现不同(Finally block to behave differently)[2023-07-21]
从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 . ...