我班上有这样的功能
showMessageSuccess(){
var that = this;
this.messageSuccess = true;
setTimeout(function(){
that.messageSuccess = false;
},3000);
}
Run Code Online (Sandbox Code Playgroud)
我怎样才能重写这个,所以我不必在'that'var中存储对'this'的引用?如果我在setTimeout中使用'this',则messageSuccess bool似乎不会更改/获取更新.
我已经从下面的链接实现了Angular 2进度微调器
https://github.com/angular/material2/tree/master/src/lib/progress-spinner
我想让它居中,然而,我似乎能够让它发挥作用的唯一方法就是删除它
display: block
Run Code Online (Sandbox Code Playgroud)
来自CSS.但是,这会导致微调器在页面上显得很大.
任何建议都会很棒.
在为桌面构建离子项目时,我使用以下命令
离子cordova构建浏览器--prod
这导致生成以下文件
建立/ main.js
但是,我希望能够在生成过程中自动为生成的文件添加版本号.所以最终会有类似的东西
建/ main.js?版本= 1.00
为了避免在每次prod构建之后需要清除浏览器缓存.
是否有这样的标志,还是我必须手动做的事情?
任何建议都会很棒!
编辑:
对于任何有兴趣的人,我的解决方案都在GitHub上!
https://github.com/RichardM99/ionic-3-version-build-file-hook
尝试使用以下内容运行prod构建时,我收到以下错误
离子cordova构建浏览器--prod
在终端中收到很多警告
FormBuilder已声明但从未使用过
即使在我的代码中,我正在导入它并使用它,例如
import { Validators, FormGroup, FormBuilder } from '@angular/forms';
public form: FormGroup;
constructor(
private formBuilder: FormBuilder
) {
setForm(){
this.form = this.formBuilder.group({
password: ['', Validators.required],
password2: ['', Validators.required]
});
}
Run Code Online (Sandbox Code Playgroud)
有人有过类似的问题吗?我猜这将与npm包更新有关.
任何建议都会很棒.
谢谢!
这是不应该做的事吗?因为我无法让它工作.
在我的控制器中我有
$scope.test = "someValue"
Run Code Online (Sandbox Code Playgroud)
在我看来
<input ng-model="test" />
Run Code Online (Sandbox Code Playgroud)
我期待发生什么
<input ng-model="someValue" />
Run Code Online (Sandbox Code Playgroud)
但是,ng-model保持设置为"test".
我该如何解决这个问题?
我有以下函数来从JavaScript中的字符串中获取所有子字符串.我知道这不正确,但我觉得我正是以正确的方式去做.任何建议都会很棒.
var theString = 'somerandomword',
allSubstrings = [];
getAllSubstrings(theString);
function getAllSubstrings(str) {
var start = 1;
for ( var i = 0; i < str.length; i++ ) {
allSubstrings.push( str.substring(start,i) );
}
}
console.log(allSubstrings)
Run Code Online (Sandbox Code Playgroud)
编辑:如果我的问题不清楚,请道歉.通过子串我的意思是字符串中所有字母的组合(不必是实际的单词)所以如果字符串是'abc'你可以有[a,ab,abc,b,ba,bac等...]谢谢对于所有的回应.
我可以像这样设置小吃店消息的持续时间
let config = new MdSnackBarConfig();
config.duration = 5000;
this.snackBar.open(element.text, 'OK', config);
Run Code Online (Sandbox Code Playgroud)
但是,我需要为多个小吃店设置持续时间,而不必每次都传入配置。
我可以以某种方式设置全局持续时间配置吗?
谢谢!
我看了下面的帖子
然而,我找不到明确的答案,我在寻找问题的根源时遇到了严重的困难,所以我在这里发帖,希望有人可以指出我正确的方向.
在我的代码中,我正在执行一个Angular HTTP帖子,它只发送基本的JSON数据,然后在成功回调中我使用AJAX将文件上传到同一个服务器.(我知道我不应该使用jQuery和Angular但是我暂时无法改变它)
它看起来像这样
var deferred = $q.defer()
// first post
$http.post(url,payload,{params: params, headers: headers)
.then(function(response) {
uploadFiles(response,deferred);
// I am also sending google analytics events here
}, function(error) {
// do error stuff
}
return deferred.promise;
// upload files function
function uploadFiles(response,deferred){
$ajax({
type: 'POST',
processData: false,
contentType: false,
data: data // this new FormData() with files appended to it,
url: 'the-endpoint-for-the-upload',
dataType: 'json',
success: function(data) {
// do success stuff here
deferred.resolve(data);
}, …Run Code Online (Sandbox Code Playgroud) 如何在rails link_to中插入HTML实体?
例如✭会给你一个明星字符,如何在引号中插入?
例如,
<%= link_to " ✭ Home", root_path %>
Run Code Online (Sandbox Code Playgroud)
谢谢!
想用连字符替换字符串中的空格,逗号和斜杠的所有实例.
目前我正在使用
myString..replace(/\s+/g, "-").replace(/\//g, "-").replace(/,/,"-");
Run Code Online (Sandbox Code Playgroud)
我知道这不好,但我尝试了一些方法
myString.replace(/s+,\//g, "-");
Run Code Online (Sandbox Code Playgroud)
但无济于事.
我应该如何组织正则表达式?