小编San*_*gde的帖子

如何在角度2中绑定HTML中组件的静态变量?

我想在HTML页面中使用组件的静态变量.如何将组件的静态变量与角度2中的HTML元素绑定?

import { Component, OnInit } from '@angular/core';
import { Observable } from 'rxjs/Rx';
@Component({
  moduleId: module.id,
  selector: 'url',
  templateUrl: 'url.component.html',
  styleUrls: ['url.component.css']
})
export class UrlComponent {

  static urlArray;
  constructor() {
  UrlComponent.urlArray=" Inside Contructor"
  }
}
Run Code Online (Sandbox Code Playgroud)
<div>
  url works!
   {{urlArray}}
</div >
Run Code Online (Sandbox Code Playgroud)

typescript angular2-services angular

61
推荐指数
3
解决办法
6万
查看次数

为什么在 WSL 中禁用了 systemd?

没有任何 systemd 命令在 WSL(Ubuntu Bash 18.04)中工作。当我跑时sudo systemctl is-active kubelet,错误是output: System has not been booted with systemd as init system (PID 1). Can't operate. : running command: sudo systemctl is-active kubelet

如何在 WSL 中启用 systemd 功能?有什么办法摆脱System has not been booted with systemd

ubuntu kubernetes windows-subsystem-for-linux minikube ubuntu-18.04

32
推荐指数
3
解决办法
6万
查看次数

以root用户身份运行弹性搜索

当我尝试使用命令启动弹性搜索5.0并获得以下错误时,我./elasticsearch得到以下错误.

[2016-11-23T13:44:09,507][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root
    at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:116) ~[elasticsearch-5.0.1.jar:5.0.1]
    at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:103) ~[elasticsearch-5.0.1.jar:5.0.1]
    at org.elasticsearch.cli.SettingCommand.execute(SettingCommand.java:54) ~[elasticsearch-5.0.1.jar:5.0.1]
    at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:96) ~[elasticsearch-5.0.1.jar:5.0.1]
    at org.elasticsearch.cli.Command.main(Command.java:62) ~[elasticsearch-5.0.1.jar:5.0.1]
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:80) ~[elasticsearch-5.0.1.jar:5.0.1]
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:73) ~[elasticsearch-5.0.1.jar:5.0.1]
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
    at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:96) ~[elasticsearch-5.0.1.jar:5.0.1]
    at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:155) ~[elasticsearch-5.0.1.jar:5.0.1]
    at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:286) ~[elasticsearch-5.0.1.jar:5.0.1]
    at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:112) ~[elasticsearch-5.0.1.jar:5.0.1]
    ... 6 more
Run Code Online (Sandbox Code Playgroud)

我试图通过切换到其他用户开始尝试sudo ./elasticsearch并得到相同的错误.如何以root用户身份开始弹性搜索?

linux elasticsearch elasticsearch-plugin

19
推荐指数
4
解决办法
4万
查看次数

Lucene搜索中如何精确匹配文本?

我尝试匹配TITLE列中的文本配置从 ASA5505 8.2 迁移到 ASA5516

我的程序看起来像这样。

Directory directory = FSDirectory.open(indexDir);

MultiFieldQueryParser queryParser = new MultiFieldQueryParser(Version.LUCENE_35,new String[] {"TITLE"}, new StandardAnalyzer(Version.LUCENE_35));        
IndexReader reader = IndexReader.open(directory);
IndexSearcher searcher = new IndexSearcher(reader);       
queryParser.setPhraseSlop(0);
queryParser.setLowercaseExpandedTerms(true);
Query query = queryParser.parse("TITLE:Config migration from ASA5505 8.2 to ASA5516");
System.out.println(queryStr);
TopDocs topDocs = searcher.search(query,100);
System.out.println(topDocs.totalHits);
ScoreDoc[] hits = topDocs.scoreDocs;
System.out.println(hits.length + " Record(s) Found");
for (int i = 0; i < hits.length; i++) {
    int docId = hits[i].doc;
    Document d = searcher.doc(docId);
    System.out.println("\"Title :\" " …
Run Code Online (Sandbox Code Playgroud)

java lucene

6
推荐指数
1
解决办法
2万
查看次数

location.go()不会以角度2重定向用户

我正在进行登录检查.一旦成功,我想将用户重定向到同一应用程序中的另一个页面.我有以下代码来做到这一点.

import { Component } from '@angular/core';
import { FormGroup, FormControl, Validators, FormBuilder } from '@angular/forms';
import { DataService } from '../services/data.service';
import {Location, LocationStrategy, PathLocationStrategy} from '@angular/common';

@Component({
  selector: 'app-login',
  templateUrl: './login.component.html',
   providers: [Location, {provide: LocationStrategy, useClass: PathLocationStrategy}],
  styleUrls: ['./login.component.css'],

})
export class LoginComponent   {

static location:Location;

  constructor(private formBuilder: FormBuilder,
              private dataService: DataService,location: Location) {
                LoginComponent.location = location;

      this.loginForm = this.formBuilder.group({
      username: this.username,
      password: this.password
    });
  }

  loginForm : FormGroup;
  username = new FormControl('', Validators.required);
  password = new FormControl('', …
Run Code Online (Sandbox Code Playgroud)

typescript angular2-routing angular

6
推荐指数
1
解决办法
1万
查看次数

打印到控制台在空手道中不起作用

我有测试微服务的场景。场景大纲:运行对象查询

Scenario Outline: Run Object Queries
    Given url homeLinks.queryUrl
    And header Content-Type =  'application/x-www-form-urlencoded'
    When method post
    Then status 200
    Then print response
Run Code Online (Sandbox Code Playgroud)

打印语句未将任何内容记录到 InteliJ 编辑器中的控制台。我也尝试在调试模式下运行。

我提到了空手道:在空手道的控制台上看不到打印语句,这没有帮助。

打印日志所需的任何配置更改?

cucumber karate

6
推荐指数
1
解决办法
3111
查看次数

如何在Angular JS控制器中使用window.onload?

如何window.onload在控制器内部使用功能。

 window.onload= function() { 
    console.log("Hi Page loaded")
   };
Run Code Online (Sandbox Code Playgroud)

该控制器不适用于整页。我想在控制器加载至少之后执行一个函数。

angularjs

4
推荐指数
1
解决办法
3万
查看次数

如何使用Node.js将FCM通知发送到所有Android设备

我想将通知发送到使用Node.Js代码中的Ionic t开发的Android应用程序。我尝试了以下代码并得到Exactly one of topic, token or condition is required.

如何无条件发送所有用户通知?

var serviceAccount = require("/path/to/config.json");

admin.initializeApp({
  credential: admin.credential.cert(serviceAccount),
  databaseURL: "https://myApp.firebaseio.com"
});

var message = {
    notification: {
      title: '$GOOG up 1.43% on the day',
      body: '$GOOG gained 11.80 points to close at 835.67, up 1.43% on the day.'
    }
  };


admin.messaging().send(message).then(res=>{
    console.log("Success",res)
}).catch(err=>{
    console.log("Error:",err)
})
Run Code Online (Sandbox Code Playgroud)

firebase firebase-authentication firebase-cloud-messaging firebase-notifications

3
推荐指数
1
解决办法
5843
查看次数

如何在Karate框架中检查数组的长度?

我从 REST Api 有 2 个不同的响应,如下所示

1. {"type":null,"title":"Request is invalid","status":"BAD_REQUEST","detail":"Please correct request and try again.","invalidParams":[{"name":"create.arg0.name","reason":"Name is required"}]}

2. {"type":null,"title":"Unicode char u0000 is not allowed","status":"BAD_REQUEST","detail":"Unicode char u0000 is not allowed"}
Run Code Online (Sandbox Code Playgroud)

我想写一个条件,如果invalidParams存在于响应中,然后比较数组的内容。如果不是,invalidParams应该为空/未定义。

 Scenario Outline: Create Asset Model with missing name and status
    Given url modelsUrl
    And request somedata
    When method POST
    Then status 400
    Then assert response.type == null
    Then match response.status == 'BAD_REQUEST'
    Then match (response.invalidParams != undefined && response.invalidParams[0].reason contains <reason>) OR (response.invalidParams == undefined)
Run Code Online (Sandbox Code Playgroud)

但与 …

karate

3
推荐指数
2
解决办法
2万
查看次数

如何在咖啡因缓存中缓存空值

我正在使用 Caffeine 缓存来存储从外部系统接收到的数据。

LoadingCache<String, String> clientCache = Caffeine.newBuilder().expireAfterWrite(1, TimeUnit.MINUTES).build(id -> {
  System.out.println("Generating new value for " + id);
  if (id.equalsIgnoreCase("1")) {
    return null;
  }
  return new Date().toString();
});

System.out.println(clientCache.get("1"));
System.out.println(clientCache.get("1"));
System.out.println(clientCache.get("2"));
System.out.println(clientCache.get("3"));
Run Code Online (Sandbox Code Playgroud)

这导致,

Generating new value for 1
null
Generating new value for 1
null
Generating new value for 2
Wed May 20 17:11:01 IST 2020
Generating new value for 3
Wed May 20 17:11:01 IST 2020
Wed May 20 17:11:01 IST 2020
Run Code Online (Sandbox Code Playgroud)

咖啡因不会在缓存中保存空值。如何在咖啡因中存储空值?

java caffeine caffeine-cache

3
推荐指数
1
解决办法
1668
查看次数

切换到第三个选项卡后 Tabhost 的内容被重置

我正在开发一个带有 3 个选项卡的 Android 应用程序。一旦我完成从服务器获取数据,我将在第一个选项卡中设置文本Tab1 数据集成功,并且新文本在视图中可见。然后我切换到tab3并切换回tab1。现在文本是在 tab1.xml 中定义的Tab 1 。那么当我在选项卡之间切换时如何保留以前的视图内容。

我的安卓代码如下

public class secondPage  extends AppCompatActivity {

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_screen);
    Intent intent = getIntent();
    String dateStrig = intent.getStringExtra("Date");
    String rData = null;
    TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
    tabLayout.addTab(tabLayout.newTab().setText("TAB 1"));
    tabLayout.addTab(tabLayout.newTab().setText("TAB 2"));
    tabLayout.addTab(tabLayout.newTab().setText("TAB 3"));
    tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);

    final ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
    final PagerAdapter adapter = new PagerAdapter
            (getSupportFragmentManager(), tabLayout.getTabCount());
    viewPager.setAdapter(adapter);

    new fetchData().execute(dateStrig);


    viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
    tabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {

        @Override
        public void onTabSelected(TabLayout.Tab tab) { …
Run Code Online (Sandbox Code Playgroud)

java xml android android-layout

2
推荐指数
1
解决办法
1376
查看次数

Oracle中如何从缓存中删除表?

我尝试在 Oracle 中添加一个表到缓存

alter table Test_Table cache;
Run Code Online (Sandbox Code Playgroud)

那么现在我怎样才能将其从缓存中删除呢?

database oracle ddl alter-table oracle11g

1
推荐指数
1
解决办法
3999
查看次数

将文件从基础映像复制到当前构建映像

尝试使用我构建的另一个自定义映像 (Y) 构建 Docker 映像 (X)。在这里,我尝试将文件夹从基本图像 Y 复制到 X,如下所示。

FROM some-image as base

COPY --from=base /root/.m2 /root

RUN mkdir -p /build
Run Code Online (Sandbox Code Playgroud)

但这会引发错误invalid from flag value base: pull access denied for base, repository does not exist or may require 'docker login': denied: requested access to the resource is denied

我怎样才能做到这一点?

containers docker dockerfile

1
推荐指数
1
解决办法
2606
查看次数