New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Markup to show how to inject Options in Configuration document #437
Comments
Good suggestion. |
@guardrex can you provide a sample project? No hurry. |
@danroth27 is this something we want to add to the document or sample? Wouldn't it be better to pass the options in a model from the action method? |
Under the section Using Options and configuration objects and immediately after the line ...
Something like this could be mentioned (with a View added to the current UsingOptions sample), which ties into the example just provided ... You can also inject @using Microsoft.Extensions.Options
@inject IOptions<MyOptions> OptionsAccessor
<!DOCTYPE html>
<html lang="en-US">
<head>
<title>Options Injection into a View</title>
</head>
<body>
<h1>Options Injection into a View</h1>
<p>
option1 = @OptionsAccessor.Value.Option1, option2 = @OptionsAccessor.Value.Option2
</p>
</body>
</html> Could possibly add an image of a browser rendering this, but it probably isn't necessary. If you want to see that in a PR, let me know. |
* Update UsingOptions sample app Takes sample to 2.0 * Update with view option injection Fixes #437 Update Update
@danroth27 @MiKom @omarpando
I just ran into a lack of knowledge (dotnet/aspnetcore#916) on what to inject into the view for Options. I thought I'd mention that a little markup showing how to do it at ...
http://docs.asp.net/en/latest/fundamentals/configuration.html#using-options-and-configuration-objects
... might be very helpful. For your example, it might be something like ...
The text was updated successfully, but these errors were encountered: