Type Program[] is not assignable to string[]TypeScript Converting a String to a numberHow to get the size of a filtered (piped) set in angular2Angular2 and TypeScript: error TS2322: Type 'Response' is not assignable to type 'UserStatus'Cast int to enum strings in TypescriptAngular Promise<void>' is not assignable to typeType 'PersonAddress[]' is not assignable to type 'Observable<PersonAddress[]>' in angular 2Promise argument type is not assignableAutomatically assign a Typescsript class to a JSON objectType '[]' is not assignable to type 'ShoppingCartItem[]'Type 'Observable<Entity[]>' is not assignable to type 'Entity[]'
Why do radiation hardened IC packages often have long leads?
Teaching a class likely meant to inflate the GPA of student athletes
Why Does Mama Coco Look Old After Going to the Other World?
Can a human be transformed into a Mind Flayer?
How to hide rifle during medieval town entrance inspection?
Varying the size of dots in a plot according to information contained in list
bash vs. zsh: What are the practical differences?
How to prove a 4D vector is a 4-Vector?
What is the logic behind charging tax _in the form of money_ for owning property when the property does not produce money?
First sign that you should look for another job?
Who won a Game of Bar Dice?
Was Self-modifying-code possible just using BASIC?
Did Apple bundle a specific monitor with the Apple II+ for schools?
If there's something that implicates the president why is there then a national security issue? (John Dowd)
Is there a set of positive integers of density 1 which contains no infinite arithmetic progression?
Can we completely replace inheritance using strategy pattern and dependency injection?
I have a problematic assistant manager, but I can't fire him
How do we say "within a kilometer radius spherically"?
How do free-speech protections in the United States apply in public to corporate misrepresentations?
I've been given a project I can't complete, what should I do?
Increase speed altering column on large table to NON NULL
UTC timestamp format for launch vehicles
How can I make 12 tone and atonal melodies sound interesting?
Are polynomials with the same roots identical?
Type Program[] is not assignable to string[]
TypeScript Converting a String to a numberHow to get the size of a filtered (piped) set in angular2Angular2 and TypeScript: error TS2322: Type 'Response' is not assignable to type 'UserStatus'Cast int to enum strings in TypescriptAngular Promise<void>' is not assignable to typeType 'PersonAddress[]' is not assignable to type 'Observable<PersonAddress[]>' in angular 2Promise argument type is not assignableAutomatically assign a Typescsript class to a JSON objectType '[]' is not assignable to type 'ShoppingCartItem[]'Type 'Observable<Entity[]>' is not assignable to type 'Entity[]'
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I have the class below. What I'd like to do is filter for the active programs and inactive programs and then get the program names, as an array of strings, for those programs.
Here is the Program class:
export class Program
ID: number;
ProgramDescription: string;
ProgramName: string;
ProgramStatus: string;
FiscalYear: string;
SupervisorID: string;
DBN: string;
IsActive: string;
Here are the methods I wrote in the service:
getPrograms(): Observable<Program[]>
return this.httpClient.get<Program[]>(environment.apiBaseURL + 'api/Program')
.pipe(
map(data => data)
);
getActivePrograms(): Observable<Program[]>
return this.getPrograms()
.pipe(
map(data => data.filter(program => program.IsActive === 'Y'))
);
getActiveProgramNames(): Observable<string[]>
return this.getActivePrograms()
.pipe(
map(data => data.filter(program => program.ProgramName.toString())
);
In getActiveProgramNames(), I'm getting the following error:
Type Program[] is not assignable to type string[]
angular typescript angular6
add a comment |
I have the class below. What I'd like to do is filter for the active programs and inactive programs and then get the program names, as an array of strings, for those programs.
Here is the Program class:
export class Program
ID: number;
ProgramDescription: string;
ProgramName: string;
ProgramStatus: string;
FiscalYear: string;
SupervisorID: string;
DBN: string;
IsActive: string;
Here are the methods I wrote in the service:
getPrograms(): Observable<Program[]>
return this.httpClient.get<Program[]>(environment.apiBaseURL + 'api/Program')
.pipe(
map(data => data)
);
getActivePrograms(): Observable<Program[]>
return this.getPrograms()
.pipe(
map(data => data.filter(program => program.IsActive === 'Y'))
);
getActiveProgramNames(): Observable<string[]>
return this.getActivePrograms()
.pipe(
map(data => data.filter(program => program.ProgramName.toString())
);
In getActiveProgramNames(), I'm getting the following error:
Type Program[] is not assignable to type string[]
angular typescript angular6
I want to cast all of the ProgramNames to an array of string.
– rds80
Mar 24 at 20:45
4
filter
isn't going to do that for you.map
can.
– R. Richards
Mar 24 at 20:46
I think @R.Richards is right and you should replace thefilter
with amap
as filter returns a collection of the same type:Program[]
.
– adz5A
Mar 24 at 20:46
Is this the right code to do that: map(data => data.map(program => program.ProgramName.toString()))
– rds80
Mar 24 at 20:50
add a comment |
I have the class below. What I'd like to do is filter for the active programs and inactive programs and then get the program names, as an array of strings, for those programs.
Here is the Program class:
export class Program
ID: number;
ProgramDescription: string;
ProgramName: string;
ProgramStatus: string;
FiscalYear: string;
SupervisorID: string;
DBN: string;
IsActive: string;
Here are the methods I wrote in the service:
getPrograms(): Observable<Program[]>
return this.httpClient.get<Program[]>(environment.apiBaseURL + 'api/Program')
.pipe(
map(data => data)
);
getActivePrograms(): Observable<Program[]>
return this.getPrograms()
.pipe(
map(data => data.filter(program => program.IsActive === 'Y'))
);
getActiveProgramNames(): Observable<string[]>
return this.getActivePrograms()
.pipe(
map(data => data.filter(program => program.ProgramName.toString())
);
In getActiveProgramNames(), I'm getting the following error:
Type Program[] is not assignable to type string[]
angular typescript angular6
I have the class below. What I'd like to do is filter for the active programs and inactive programs and then get the program names, as an array of strings, for those programs.
Here is the Program class:
export class Program
ID: number;
ProgramDescription: string;
ProgramName: string;
ProgramStatus: string;
FiscalYear: string;
SupervisorID: string;
DBN: string;
IsActive: string;
Here are the methods I wrote in the service:
getPrograms(): Observable<Program[]>
return this.httpClient.get<Program[]>(environment.apiBaseURL + 'api/Program')
.pipe(
map(data => data)
);
getActivePrograms(): Observable<Program[]>
return this.getPrograms()
.pipe(
map(data => data.filter(program => program.IsActive === 'Y'))
);
getActiveProgramNames(): Observable<string[]>
return this.getActivePrograms()
.pipe(
map(data => data.filter(program => program.ProgramName.toString())
);
In getActiveProgramNames(), I'm getting the following error:
Type Program[] is not assignable to type string[]
angular typescript angular6
angular typescript angular6
edited Mar 24 at 20:46
rds80
asked Mar 24 at 20:42
rds80rds80
1469
1469
I want to cast all of the ProgramNames to an array of string.
– rds80
Mar 24 at 20:45
4
filter
isn't going to do that for you.map
can.
– R. Richards
Mar 24 at 20:46
I think @R.Richards is right and you should replace thefilter
with amap
as filter returns a collection of the same type:Program[]
.
– adz5A
Mar 24 at 20:46
Is this the right code to do that: map(data => data.map(program => program.ProgramName.toString()))
– rds80
Mar 24 at 20:50
add a comment |
I want to cast all of the ProgramNames to an array of string.
– rds80
Mar 24 at 20:45
4
filter
isn't going to do that for you.map
can.
– R. Richards
Mar 24 at 20:46
I think @R.Richards is right and you should replace thefilter
with amap
as filter returns a collection of the same type:Program[]
.
– adz5A
Mar 24 at 20:46
Is this the right code to do that: map(data => data.map(program => program.ProgramName.toString()))
– rds80
Mar 24 at 20:50
I want to cast all of the ProgramNames to an array of string.
– rds80
Mar 24 at 20:45
I want to cast all of the ProgramNames to an array of string.
– rds80
Mar 24 at 20:45
4
4
filter
isn't going to do that for you. map
can.– R. Richards
Mar 24 at 20:46
filter
isn't going to do that for you. map
can.– R. Richards
Mar 24 at 20:46
I think @R.Richards is right and you should replace the
filter
with a map
as filter returns a collection of the same type: Program[]
.– adz5A
Mar 24 at 20:46
I think @R.Richards is right and you should replace the
filter
with a map
as filter returns a collection of the same type: Program[]
.– adz5A
Mar 24 at 20:46
Is this the right code to do that: map(data => data.map(program => program.ProgramName.toString()))
– rds80
Mar 24 at 20:50
Is this the right code to do that: map(data => data.map(program => program.ProgramName.toString()))
– rds80
Mar 24 at 20:50
add a comment |
1 Answer
1
active
oldest
votes
Try with map
getActiveProgramNames(): Observable<string[]>
return this.getActivePrograms()
.pipe(
map(data => data.map(program => program.ProgramName.toString())
);
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55328378%2ftype-program-is-not-assignable-to-string%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Try with map
getActiveProgramNames(): Observable<string[]>
return this.getActivePrograms()
.pipe(
map(data => data.map(program => program.ProgramName.toString())
);
add a comment |
Try with map
getActiveProgramNames(): Observable<string[]>
return this.getActivePrograms()
.pipe(
map(data => data.map(program => program.ProgramName.toString())
);
add a comment |
Try with map
getActiveProgramNames(): Observable<string[]>
return this.getActivePrograms()
.pipe(
map(data => data.map(program => program.ProgramName.toString())
);
Try with map
getActiveProgramNames(): Observable<string[]>
return this.getActivePrograms()
.pipe(
map(data => data.map(program => program.ProgramName.toString())
);
answered Mar 24 at 20:51
Derviş KayımbaşıoğluDerviş Kayımbaşıoğlu
16.1k22142
16.1k22142
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55328378%2ftype-program-is-not-assignable-to-string%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I want to cast all of the ProgramNames to an array of string.
– rds80
Mar 24 at 20:45
4
filter
isn't going to do that for you.map
can.– R. Richards
Mar 24 at 20:46
I think @R.Richards is right and you should replace the
filter
with amap
as filter returns a collection of the same type:Program[]
.– adz5A
Mar 24 at 20:46
Is this the right code to do that: map(data => data.map(program => program.ProgramName.toString()))
– rds80
Mar 24 at 20:50