我试图使用typescript函数中的location.go服务导航到特定的URL.它会更改浏览器中的URL,但URL的组件不会反映在屏幕中.它保留在登录(实际)屏幕上 - 例如:
constructor(location: Location, public _userdetails: userdetails){
this.location = location;
}
login(){
if (this.username && this.password){
this._userdetails.username = this.username;
this.location.go('/home');
}
else{
console.log('Cannot be blank');
}
}
Run Code Online (Sandbox Code Playgroud)
我缺少一个编译方法或刷新方法吗?
我希望使用worker运行一个函数(在后台).数据来自http请求.我正在使用模拟计算(e.data[0] * e.data[1] * xhrData.arr[3])(替换为返回实际算法结果的函数),如下所示:
var ajax = function() {
var prom = new Promise(function(resolve, reject){
if (!!XMLHttpRequest) {
var xhttp = new XMLHttpRequest();
xhttp.onload = function () {
if (this.readyState == 4 && this.status == 200) {
resolve(JSON.parse(this.responseText));
}
};
// Cache Logic - Will be adding logic to check cache
// if test.json is in cache.
// If it is then fetch res from cache
// There will be multiple XHR requests in parallel, not one …Run Code Online (Sandbox Code Playgroud) 我正在用我的项目构建一个简单的cordova应用程序.它有2级嵌套(主要路线) - >儿童路线 - >(另一条儿童路线).When trying to browse to the 2nd level (another child route)我得到一个错误说Exception: Error during instantiation of t! Primary outlet already registered.第一级工作正常.我没有在任何模板中使用路由器插座两次.在浏览器和android的仿真中问题是一样的.
附上铬检查下面.
我的HTML文件
<html>
<head>
<base href="./">
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *">
<meta name="format-detection" content="telephone=no">
<meta name="msapplication-tap-highlight" content="no">
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
<link rel="stylesheet" type="text/css" href="css/index.css">
<link href="assets/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="assets/css/style.css" rel="stylesheet" type="text/css" />
<link href="assets/css/skins/skin-white.css" rel="stylesheet" type="text/css" />
<title>Hello …Run Code Online (Sandbox Code Playgroud) 我试图在运行时将角度代码的*ngIf指令分配给模板.无法找到办法.view/templateref是一个选项吗?或者有一个不同的方式和一个更容易的方式.有可能首先吗?
更新:
代码有点混乱和混乱,所以避免它.但是这里是DOM代码的外观,以及为什么我需要动态添加内置结构指令.
<div>
<input type="text" [value]="userProvidedValue">
<textarea [value]="someDynamicDOMCodefromWYSIWYG">
<!-- user provided provided code or dynamic code -->
</textarea>
</div>
<div>
<select *ngIf="fetchArraywithHttpFromuserProvidedValue">
<option *ngFor="let val of fetchArraywithHttpFrom-userProvidedValue" value=""></option>
</select>
</div>
<div>
<ng-template>
<!-- Some User provided code or dynamic code which might need to use *ngIf OR *ngFor -->
<!-- The *ngIf OR *ngFor will be added dynamically based on a manipulator function which is decided from the value of fetchArraywithHttpFromuserProvidedValue -->
</ng-template>
</div>
Run Code Online (Sandbox Code Playgroud)
我正在根据userProvidedValue值执行获取请求,并且获取请求的结果决定了fetchArraywithHttpFromuserProvidedValue …
我在一个 angular-cli 项目中。我正面临 CSS 的问题。这在某种程度上是一个非代码问题,偏离了 Stack Overflow 放置代码的需求。但希望它不会被标记为关闭。这是背景:
我有很多不必要的 CSS 挥之不去。在构建过程中,我需要对不必要的 CSS 进行摇树。有没有你可以帮我的。
这是正在发生的事情的背景:
styles.css(由 ng-cli 连接的style1.css,style1.css等)以帮助更快地清理 CSS 并移至组件的默认角度仿真。但是随着我的应用程序变得越来越大,我无法手动跟踪 CSS。选项:我看到手动摇树是一个问题。所以我看到周围有一些 CSS 摇树器,但由于 Angular cli 与多个组件一起工作,我认为需要 CSS 摇树器的 cli 集成。我找不到 cli 与 build 合并的一个。
问题:有人对如何集成有任何建议,或者是否有 CSS-tree Shaker 社区项目?我没有使用过原理图。
尝试从组件订阅HTTP-GET的解析响应.获取错误说.map不是从HTTPService或组件类使用的函数.
Httpdemo.getResponse().map(res => res.json()).subscribe((cities)=>{
this.cities = cities.cities;
console.log(this.cities);
});
Run Code Online (Sandbox Code Playgroud)
但以下工作:
Httpdemo.getResponse().subscribe((cities)=>{
this.cities = JSON.parse(cities._body).cities;
console.log(this.cities);
});
Run Code Online (Sandbox Code Playgroud)
解析在Httpdemo服务中也不起作用.
return this.http.get('./app/cities.json').map(res => res.json())
Run Code Online (Sandbox Code Playgroud)
我的代码中的用法有什么问题?
我无法获得我的自定义元素的 nativeElement 的引用。我有一个这样的模板:
<div #testone>
<my-feature-cmp><my-feature-cmp>
<my-feature-cmp><my-feature-cmp>
<my-feature-cmp><my-feature-cmp>
<div>
Run Code Online (Sandbox Code Playgroud)
用于访问的代码:@ViewChild('testone') el: ElementRef;
当我这样做时,我得到了元素引用 -> console.log(this.el.nativeElement)
第二种模板
<my-feature-cmp></my-feature-cmp>
<my-feature-cmp></my-feature-cmp>
<my-feature-cmp></my-feature-cmp>
Run Code Online (Sandbox Code Playgroud)
用于访问的代码:
@ViewChildren(MyFeatureCmp) el: MyFeatureCmp;
Run Code Online (Sandbox Code Playgroud)
执行此操作时出现本机元素错误 ->
console.log(this.el.nativeElement)
Run Code Online (Sandbox Code Playgroud)
当我这样做时,我得到了类引用并且没有 nativeElement ->
console.log(this.el)
console.log(this.el.toArray())
Run Code Online (Sandbox Code Playgroud)
问题是如果我想更改标签属性,如何访问自定义组件的本机元素。其次,无论我以何种方式访问它们,如果我手动更改自定义组件的属性,它是否也会在更改后被检测为更改?
无法启用XDEBUG.任何帮助或检查是否已启用且未反映?我在PHP7上,正在使用Xdebug 2.4.0rc2.PHP.INI设置如下:
[XDebug]
zend_extension="C:/php/ext/php_xdebug.dll"
xdebug.remote_enable = on
xdebug.remote_host = localhost
xdebug.remote_port = 10000
xdebug.remote_handler = dbgp
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 1
xdebug.profiler_output_dir = "profilerlogs"
xdebug.profiler_output_name = cachegrind.out.%p
Run Code Online (Sandbox Code Playgroud)
无法启用它.步骤是正确的,但也没有显示安装在phpinfo()中.
php.exe可以连续运行数周或数月的应用程序运行,而不会崩溃吗?
例如:UDP或HTTP/TCP服务器(或网络)应用程序.我听说它还没有为长时间运行的应用程序开发.我相信我们可以在linux和Windows中使用pthreads/events来进行多线程/并行,以支持为进程生成的负载并开发长时间运行的应用程序.但不确定会有多稳定.任何能够使用pthreads和长期运行的PHP应用程序发表评论并提供开发资源指导的人?
我创建了一个 Injectable,其中包含要使用的同一文件中的全局变量的声明。我能够让它在代码中工作。但在我的测试中,声明失败并出现未定义的错误。
declare var myGlobal;
@Injectable()
export class HttpService {
constructor() {
console.log(myGlobal);
}
}
Run Code Online (Sandbox Code Playgroud)
我正在测试一个组件,并且需要此服务作为组件测试的测试台中的提供者。
以下是它的调用方式:
@Component({
...
})
export class AppComponent {
constructor(_h: HttpService) {
}
ngOnInit(): void {
this._h.fileUrl = window.location.href;
this.getSettings(this._h.settingsSrc);
}
}
Run Code Online (Sandbox Code Playgroud)
以下是测试中服务的声明
beforeEach(async(() => {
const settingsFile = 'json';
TestBed.configureTestingModule({
declarations: [
AppComponent,
MenubarComponent,
],
imports: [
HttpClientModule,
],
providers: [
HttpService
],
}).compileComponents();}))
it('getSettings() tests', inject([HttpService], async(async (_h: HttpService) => {
const cmp = new AppComponent(_h);
await cmp.ngOnInit(); // this is where the …Run Code Online (Sandbox Code Playgroud) angular ×8
javascript ×4
angular-cli ×2
components ×2
php ×2
android ×1
cordova ×1
css ×1
debugging ×1
events ×1
http ×1
jasmine ×1
karma-runner ×1
location ×1
networking ×1
php-7 ×1
pthreads ×1
router ×1
testing ×1
viewchild ×1
web-worker ×1
xdebug ×1