*Problem*

*How to call function (GetLabelTextForEmployee) on angular component on 
employees.component.ts and employees.component.html ?*

I work on asp.net core 2.1 web API with angular 6.

I make function on web API name GetReferenceFileData to get text of label 
from

database and show on view on employees.component.html based on Reference 
Table .

This function work on web API but in angular I dont know how to call inside 
angular ?

This is my function :

[HttpGet("{tableName}/{FieldName}")]
        [Produces("text/plain")]
        public string GetReferenceFileData([FromRoute] string tableName, 
[FromRoute] string FieldName)
        {
          var Result =  (from h in _context.ReferenceFiles
                          where h.TableName == tableName && h.FieldName == 
FieldName
                          select h.LabelText).FirstOrDefault();
            if(Result==null)
            {
                Result = "Not Exist";
            }

            return (Result);


        }

Function above return only one string value for label as Scalar Value

What I have tried:

1- create Reference.model.ts :

export class Reference {
    Code : number  ;
    TableName : string ;
    FieldName : string ;
    LabelText : string

2- on API service I create Function Below :

GetLabelTextForEmployee(tableName:string,FieldName : string)
              {
                return this.http.get('https://localhost:44326/api/reference/' + 
tableName + '/' + FieldName);
              }

3- On employees.component.ts (this is my problem)

*What i write here to call function GetLabelTextForEmployee*

4- On employees.component.html

*How to replace label for employeeId by function GetLabelTextForEmployee ?*

<div class="form-group">  
<label for="employeeId">employee Id:</label> replace by 
GetLabelTextForEmployee('Employees','EmployeeId') 
</div> 

Sample data ReferenceTable

Code  tableName   FieldName   LabelText
111   Employees   EmployeeId  EmployeeCode

Result of calling

GetLabelTextForEmployee('Employees','EmployeeId')

it suppose Return EmployeeCode

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to