小编mec*_*b95的帖子

无法绑定,因为它不是选择器组件的已知属性

我想将变量从一个组件传递到另一个组件,并且我正在使用 @input

这是我的父组件:

@Component({
    selector: 'aze',
    templateUrl: './aze.component.html',
    styleUrls: [('./aze.component.scss')],
    providers: [PaginationConfig],
})

export class azeComponent implements OnInit {
    public hellovariable: number = 100;
}
Run Code Online (Sandbox Code Playgroud)

这是父组件的模板:

<app-my-dialog [hellovariable]="hellovariable"></app-my-dialog>
Run Code Online (Sandbox Code Playgroud)

这是我的子组件:

@Component({
  selector: 'app-my-dialog',
  templateUrl: './my-dialog.component.html',
  styleUrls: ['./my-dialog.component.css']
})

export class MyDialogComponent implements OnInit {
  @Input() hellovariable: number;
  constructor() { }

  ngOnInit() {
    console.log(hellovariable);
  }
Run Code Online (Sandbox Code Playgroud)

这是子模板:

 <h3>Hello I am {{hellovariable}}<h3>
Run Code Online (Sandbox Code Playgroud)

这是app.module.ts:

@Component({
    selector: 'aze',
    templateUrl: './aze.component.html',
    styleUrls: [('./aze.component.scss')],
    providers: [PaginationConfig],
})

export class azeComponent implements OnInit {
    public hellovariable: number = 100; …
Run Code Online (Sandbox Code Playgroud)

javascript typescript angular angular8

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

使用 jquery 更改输入的 id

您好,我在表中有一个带有值的 td,当单击按钮时,我已将此 td 更改为文本类型的输入。

现在我想用 td 元素的 id 更改新输入的 id,所以我有一个例外:

input.id 不是函数

这是我的代码js:

$("tr.forc td.TdbeforeForcage").each(function () {
    var html = $(this).html();
    var input = $('<input class="numberforce" style="width:50%" type="text" />');
    var IdTd = $(this).attr("id");
    input.val(html);
    input.id(IdTd); // Here trying to change id of input with id of td 
    $(this).html(input);

    if (html.indexOf('&nbsp;') > -1) {
      var newValue = html.replace('&nbsp;', ' ');
      $(this).find('input.numberforce').val(newValue)
    }
});
Run Code Online (Sandbox Code Playgroud)

html javascript jquery

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

标签 统计

javascript ×2

angular ×1

angular8 ×1

html ×1

jquery ×1

typescript ×1