【发布时间】:2015-04-13 20:39:45
【问题描述】:
快速提问
我正在使用角带来显示一些警报,每个警报都在不同的变量中,但我想避免这样做,有人告诉我使用 lodash 的_.extend,但是我应该如何使用它特殊情况?
var loaderAlert1 = $alert({
animation: 'fx-bounce-right',
content: 'Loading content, please wait...',
container: '.alerts-container',
type: 'info',
show: true
}),
loaderAlert2 = $alert({
animation: 'fx-bounce-right',
content: 'Adding Line to BetSlip',
container: '.alerts-container',
type: 'info',
show: false
}),
loaderAlert3 = $alert({
animation: 'fx-bounce-right',
content: 'Loading your messages, please wait...',
container: '.alerts-container',
type: 'info',
show: false
});
如您所见,几乎相同,但在某些情况下,show attr 设置为 true 或 false,content: 也会更改。
我调用此警报的方式:loaderAlert1.show() 或 loaderAlert1.hide() 等等...
所以我想做类似的事情
var loaderAlert = $alert({
animation: 'fx-bounce-right',
content: 'Loading content, please wait...',
container: '.alerts-container',
type: 'info',
show: true
});
loaderAlert = {content: 'loading something else'};
loaderAlert = {content: 'loading something GREAT'};
loaderAlert = {content: 'loading only ROCK N ROLL'};
我在这里只声明一个变量,然后一旦我调用该变量,我可以更改content:...但我不知道如何_.extend、here is the function I mentioned。
【问题讨论】:
标签: javascript angularjs underscore.js lodash