小编Ram*_*a S的帖子

如何将值从 ts 文件传递​​到 angular 2+ 中同一组件中的 scss 文件?

这是我的组件

export class myComponent implements onInit {

private outageCount;

ngOnInit(){

    ....subscribe((data) => {
    this.outageCount = Object.keys(data).length;

})
}
Run Code Online (Sandbox Code Playgroud)

我需要之前将 outageCount 传递给我的 css CONTENT

:host ::ng-deep app-settings-panel {
    &:before{
        //content:"4";
        content:attr(outageCount);
        background: #941313;
        position: absolute;
        top: 3px;
        left: 22px;
        border-radius: 50%;
        height: 13px;
        width: 13px;
        border: 1px solid #ffffff;
        color: white;
        font-size: 8px;
        text-align: center;
        line-height: 13px;
    }
Run Code Online (Sandbox Code Playgroud)

我如何将 outageCount 值从我的组件传递给 css :before content

任何建议,将不胜感激!

css sass angular2-template angular

8
推荐指数
2
解决办法
8232
查看次数

如何将ajax get请求数据传递给nodejs GET路由?

这是我的ajax请求调用

  $.ajax({
    url: '/refresh',
    type: 'GET',
    contentType: "application/json",
    data: {
        Name: $("#inputName").val(),
        Url: $("#inputUrl").val()
    },
    success: function(data) {
        console.log('form submitted.' + data);
    }
  });
Run Code Online (Sandbox Code Playgroud)

这是nodejs中的GET路由

app.get('/refresh', function(req, res) {
            console.log("My data" + JSON.stringify(req.body));
            //other operations
        }
Run Code Online (Sandbox Code Playgroud)

我怎样才能获取从我的js中的ajax调用传递的数据?请帮忙!!多谢!

javascript ajax node.js express

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

如何在typehaead Angular 4中使用limitTo?

如何将Typeahead结果的数量限制为5或Angular 4中的某些内容?我在这里附上官方的plunker链接.我无法使用|limitTo

http://embed.plnkr.co/gV6kMSRlogjBKnh3JHU3/

这是模板

<section class="col-sm-12">
    <div class="search-results style-3">
      <input type="text" [value]="query"
        ngxTypeahead
        [taUrl]="url"
        [taParams]="params"
        (taSelected)="handleResultSelected($event)"
      >
    </div>
  </section>
Run Code Online (Sandbox Code Playgroud)

这是ts文件

export class AppComponent {

  title = 'This is Angular TypeAhead v' + systemConfig.map['ngx-typeahead'].split('@')[1].split('/')[0];

  public url = 'http://suggestqueries.google.com/complete/search';
  public params = {
    hl: 'en',
    ds: 'yt',
    xhr: 't',
    client: 'youtube'
  };
  public query = '';

  handleResultSelected (result) {
    this.query = result;
  }

  generateWord() {
    return chance.word();
  }
}
Run Code Online (Sandbox Code Playgroud)

javascript typeahead angular

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

如何使用angular CLI排除lint目录下的所有文件?

我们可以通过这种方式排除 node_modules。

  "lint": [
        {
          "project": "src/main/webapp/app/file.json",
          "exclude": "**/node_modules/**"
        }
    ]
Run Code Online (Sandbox Code Playgroud)

但是如何排除一个目录下的所有文件呢?

我试过下面的方法。它不工作

"exclude": [
 "**/*whatever.pipe.ts", 
 "**/*whatever_else.component.ts"
]
Run Code Online (Sandbox Code Playgroud)

所以这是我当前的目录路径 "src/main/assets/js/ngx-typeahead"

我必须从 linting 中排除此目录下的所有文件。

我怎样才能做到这一点?

任何建议,将不胜感激。

lint angular-cli angular

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

如何对CombineLatest中的每个函数进行单独的错误处理?

我需要在此CombineLatest中处理每个函数的错误情况。我将在下面添加代码

const combined = combineLatest(
  this.myservice1.fn1(param),
  this.myservice2.fn2(), 
  this.myservice3.fn3());

const subscribe = combined.subscribe(
  ([fn1,fn2, fn3]) => {
    // operations i need to do
  },
  // how to handle error for fn1, fn2, fn3 separately
  (error) => {
  }
);
Run Code Online (Sandbox Code Playgroud)

任何帮助,将不胜感激!

error-handling rxjs angular combinelatest

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