I want to create a function that generate me a random string or number.

My function in ts like this:

```
  randomString() {
    let chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
    let string_length = 8;
    let randomstring = '';
    for (let i = 0; i < string_length; i++) {
      let rnum = Math.floor(Math.random() * chars.length);
      randomstring += chars.substring(rnum, rnum + 1);
    }
  }

```

Html code

```
    <form [formGroup]="addProductForm">
          <div class="input-field col s12">
                <input formControlName="Line_num" type="button" value="Create Random String" onClick="randomString();">  
  <input type="text" name="Line_num" value="">    
            </div>
    <form>

```

When I click button , show this error:
Uncaught ReferenceError: randomString is not defined at TMLInputElement.onclick

Now, 
I change this,

```
this.addProductForm = this.fb.group({
    'Line_num': new FormControl(this.randomString(), Validators.required),
    });

```

In function 

```
   randomString() { 
  return Math
    .random() // Create a random number
    .toString(36) // Convert it to string (26 letters + 10 numbers)
    .split('') // Creates an array of those letters
    .slice(-8) // Take the last height ones
    .join(''); // Join them back to create a string
}

```

Html code

```
 <form [formGroup]="addProductForm">
    <div class="input-field col s12">
        <input type="text" formControlName="Line_num" name="Line_num">
</div>
</form>

```

The problem has been resolved