我正在使用ajax调用来执行服务文件中的功能,如果响应成功,我想将页面重定向到另一个URL.目前,我通过使用简单的js"window.location = response ['message'];"来做到这一点.但我需要用angularjs代码替换它.我在stackoverflow上看了各种解决方案,他们使用了$ location.但我是棱角分明并且很难实现它.
$http({
url: RootURL+'app-code/common.service.php',
method: "POST",
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
dataType: 'json',
data:data + '&method=signin'
}).success(function (response) {
console.log(response);
if (response['code'] == '420') {
$scope.message = response['message'];
$scope.loginPassword = '';
}
else if (response['code'] != '200'){
$scope.message = response['message'];
$scope.loginPassword = '';
}
else {
window.location = response['message'];
}
// $scope.users = data.users; // assign $scope.persons here as promise is resolved here
})
Run Code Online (Sandbox Code Playgroud) 我有一个我想要迭代的字符串列表,但我希望能够使用搜索词来过滤它们.像这样:
<div *ngFor="#item in list | search: searchTerm">{{ item }}</div>
Run Code Online (Sandbox Code Playgroud)
我的问题是:如何检查管道是否返回列表的空子集?
换句话说,如果所有字符串都不匹配搜索词,我想显示一条消息:"No matches".
我学习ngxs但是当我应该用我无法理解patchState和setState?有什么不同?
const state = ctx.getState();
let data = this.service.list();
ctx.setState({
...state,
feedAnimals: data
});
Run Code Online (Sandbox Code Playgroud)
与
let data = this.service.list();
ctx.patchState({
feedAnimals: data
});
Run Code Online (Sandbox Code Playgroud) 通过项目中的一种IConfiguration方法移动课程后,GetValue<T>停止工作。用法是这样的:
using Newtonsoft.Json;
using System;
using System.Net;
using System.Text;
using Microsoft.Extensions.Configuration;
namespace Company.Project.Services
{
public class MyService
{
private readonly IConfiguration _configuration;
public string BaseUri => _configuration.GetValue<string>("ApiSettings:ApiName:Uri") + "/";
public MyService(
IConfiguration configuration
)
{
_configuration = configuration;
}
}
}
Run Code Online (Sandbox Code Playgroud) 我想要一个擦拭动画看起来像水滴在一滴内.它目前是一个正方形,在下降标志的顶部有一个波浪动画.它正确地完成了波浪动画,但是我不能让它留在掉落中并且也填满了.
我越来越近,但我仍然需要实际的徽标至少在圈内.
我的进步:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SVG Line Animation Demo</title>
</head>
<body>
<style>
.st0{fill:none;stroke:#000000;stroke-width:4;stroke-miterlimit:5;}
.st1{fill:none;stroke:#000000;stroke-width:3;stroke-miterlimit:5;}
#logo2 {
width: 150px !important;
height: 150px !important;
position: relative;
margin-top: -100px;
}
#banner {
border-radius: 50%;
width: 150px;
height: 150px;
background: #fff;
overflow: hidden;
backface-visibility: hidden;
transform: translate3d(0, 0, 0);
z-index: -1;
margin-bottom: -50px;
}
#banner .fill {
animation-name: fillAction;
animation-iteration-count: 1;
animation-timing-function: cubic-bezier(.2, .6, .8, .4);
animation-duration: 4s;
animation-fill-mode: forwards;
} …Run Code Online (Sandbox Code Playgroud)我想知道如何在没有任何手动服务注入和运行的情况下从模块中运行服务,就像这样RouterModule做一样。
@NgModule({
imports: [
BroserModule,
MyModuleWithServicesThatShouldAutoRun,
]
})
export class AppModule { }
Run Code Online (Sandbox Code Playgroud) 使用beforeinstallprompt事件时我应该使用哪种类型?
我试过BeforeInstallPromptEvent打字,但给了我一个错误:
export class PwaService {
//promptEvent: BeforeInstallPromptEvent;
promptEvent;
constructor(private swUpdate: SwUpdate, platform: PlatformService) {
if(platform.isBrowser()){
swUpdate.available.subscribe(event => {
/*if (askUserToUpdate()) {
window.location.reload();
}*/
});
window.addEventListener('beforeinstallprompt', event => {
this.promptEvent = event;
});
}
}
install(): void {
if(this.promptEvent){
this.promptEvent.prompt();
}
}
}
Run Code Online (Sandbox Code Playgroud) 我举个例子,这是我的图表(请注意,我已经降低了贝塞尔强度以减少线条的错误):

我希望它以这种方式呈现:

请原谅画得很糟糕的红线,我只是用MS Paint来画得很快,呵呵。
我希望我的图表看起来像第二个示例中的红线,其中曲线的边缘是我的值,而不是0.1f我的值点之前的 x。我还注意到,当使用xAxis启用时,它无法正确显示我的值,其中整数从 0 到 4(含),但显示为浮点数,如 0.9、1.9、...、3.9,与贝塞尔曲线边缘匹配。我相信这是错误的。
根据记录,贝塞尔模式正在应用于我的数据集dataSet.mode = LineDataSet.Mode.CUBIC_BEZIER。
我无法按照主存储库上的自述文件示例来设置库。我不想使用 ES6、AMD 或任何需要构建步骤的方法。
有一种方法可以在 Select2 中添加自定义用户输入,而无需使用该tags模式。
也就是说,创建一个保留选择样式的自定义选择输入,而不使用内联块小标签。
另外,我发现了很多使用 AJAX 和其他主题外的答案,但没有一个能解决我的问题。