小编Sup*_*del的帖子

角度 11 中代码“$event.target.checked”中的问题

在我的代码中使用此示例:https://stackblitz.com/edit/angular-rskaug ?file=src%2Fapp%2Fapp.component.html

组件中的 HTML

<td><input type="checkbox" (change)="onChange(employee.id, $event.target.checked)"></td>
Run Code Online (Sandbox Code Playgroud)

组件中的打字稿

onChange(id: any, isChecked: boolean) {
    const idFormArray = <FormArray>this.myForm.controls.employeeRelatedId;

    if (isChecked) {
      idFormArray.push(new FormControl(id));
    } else {
      let index = idFormArray.controls.findIndex(x => x.value == id)
      idFormArray.removeAt(index);
    }
  }
Run Code Online (Sandbox Code Playgroud)

错误详情

类型“EventTarget”上不存在属性“checked”。

45 <input type="checkbox" (change)="onChange(employee.id, $event.target.checked)">

typescript angular angular11

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

需要帮助使用循环生成三个块

在3块代码之后,想要生成使用循环/数组来制作短代码.我知道使用循环并不是一件大事,但对我来说很难用变量"openFile"来改变计数器,我希望计数器增量变量" openFile"就像openFile1,openFile2和openFile3一样,每次迭代循环.

$(function() {

            var openFile1 = function(event) {
        var input = event.target;
        var reader = new FileReader();
        reader.onload = function(){
          var dataURL = reader.result;
          var output = document.getElementById('img1');
          output.src = dataURL;
        };
        reader.readAsDataURL(input.files[0]);
      };



      var openFile2 = function(event) {
        var input = event.target;
        var reader = new FileReader();
        reader.onload = function(){
          var dataURL = reader.result;
          var output = document.getElementById('img2');
          output.src = dataURL;
        };
        reader.readAsDataURL(input.files[0]);
      };

      var openFile3 = function(event) {
        var input = event.target;
        var reader = new FileReader(); …
Run Code Online (Sandbox Code Playgroud)

javascript arrays jquery arraylist

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

无法在 Angular 7 应用程序中覆盖 Bootstrap

在 Angular 应用程序中,我试图breadcrumb通过删除分隔线来覆盖我的风格。我用https://getbootstrap.com/docs/4.2/components/breadcrumb/#example。但它不起作用。

这是我的 angular.json 文件脚本

    {
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "ibo": {
      "root": "",
      "sourceRoot": "src",
      "projectType": "application",
      "prefix": "app",
      "schematics": {
        "@schematics/angular:component": {
          "styleext": "scss"
        }
      },
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist/ibo",
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.app.json",
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
            "stylePreprocessorOptions": {
                "includePaths": [
                  "node_modules/bootstrap",
                  "src/styles"
                ]
             },
            "scripts": [
              "node_modules/popper.js/dist/umd/popper.min.js",
              "node_modules/jquery/dist/jquery.min.js",
              "node_modules/bootstrap/dist/js/bootstrap.min.js"
            ],
            "styles": [
               "node_modules/font-awesome/css/font-awesome.min.css",
               "node_modules/bootstrap/dist/css/bootstrap.min.css",
               "src/styles/styles.scss",
            ], …
Run Code Online (Sandbox Code Playgroud)

sass twitter-bootstrap angular angular7

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

使用传统的 foreach 循环替换 C# 中 List 中特定索引处的项目

这是我的代码来解决这个问题。 错误详细信息:索引超出范围。必须为非负数且小于集合的大小。

List<string> mylist = new List<string>();
mylist.Add("Val1");
mylist.Add("Val2");
mylist.Add("Val3");

int i = 1;
int totalLenngth = mylist.Count;
foreach (var item in mylist)
{
    if (i == totalLenngth) {
      //mylist.Remove(bro);
        mylist.RemoveAt(i);
        mylist.Add("Val4");
    }
    i++;
}
Run Code Online (Sandbox Code Playgroud)

c#

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