I have a view rendering written in .cshtml. The .cshtml in turn refers .js files (written as angular2 apps). I want to pass a parameter from the .cshtml to the angular2 app. How do I do this? I am using angular-cli to generate the angular2 app.
Passing parameter to angular2 app from a .cshtml view rendering in SiteCore
212 Views Asked by user3547774 At
2
There are 2 best solutions below
0
Jeroen
On
Jens answer will definitely work. You could also pull the data with a separate call through Sitecore Service Client in Angular if you are concerned with adding variables to global scope or don't want to have additional dependencies on the view. This will have a small performance impact as an additional request would need to be made.
Related Questions in ANGULAR
- Firebase link existing user to anonymous account?
- It doesnt always show all the books on my homepage
- Google adsense ads.txt status cannot be not found
- When I navigate to the URL'http://localhost:4200/', it redirects me back
- Ionic Angular Standalone ion-icon are not showing at all
- How to make Angular understand that view child is of a specific type, not a general ElementRef?
- vscode, debug angular, first time, doesn't debug, 2nd time stops at main.js then it's ok
- How to perform CRUD operations on a static JSON array in Angular? (without API)
- Ngrx props<>() method in createAction()
- How to animate rotation of an image inside input control?
- Detecting click inside and outside of the listening component in Angular
- Angular - type guard not narrowing types
- In node_modules file i am getting Angular genric error while using fontawesome in angular12
- Angular 16 sending null values to API
- GoogleCloud Error: Not Found The requested URL was not found on this server
Related Questions in SITECORE
- How to Customize Sitecore Copy operation
- Joomla 5..0.3 delay in search
- What's the event for when a Branchitem has finished creating?
- Convert Sitecore data sources to Guid, programatically
- How to specify an existing ItemId While uploading Media Items to Sitecore XM Cloud using UploadMedia mutation?
- Sitecore to WordPress migration
- Why changing template in Sitecore using powershell script creates a version in English language even if there no version exists?
- I want to convert sitecore search facet filter from multiple to single
- Sitecore - select fields and write to an excel sheet by changing the field names in Powershell
- Coveo for Sitecore: Precondition failed: The parameter 'p_ApiKey' must not be an empty string
- In Sitecore 10, why would my Content Editor Panel not open
- Not loading CSS files after login to my sitecore instance
- AWS - Amazon.Extensions.S3.Encryption.AmazonS3EncryptionClientBase is attempting to implement an inaccessible interface
- Cannot use import statement outside a module - jest + nextj.js
- To get the sitecore username who created sitepage
Related Questions in VIEWRENDERING
- What is the explanation of observing a constant data change in SwiftUI View
- Unable to update instantly the view of ion-select-option
- How to Call a WebController From a RestController And Get A Rendered Template in Response in String In Java
- Template Inheritance doesnot work in Django
- Xamarin forms iOS UIView Renderer intermittent OnElementChanged in some cases
- SwiftUI: How to get the HostingController View/Content maxHeight by given width?
- How to send an object to .marko template and render its properties dynamically, in a table
- Micronaut view rendering without template engine
- Should I prefer rendering layout at run time or Include it in XML layout?
- AppCompatActivity in xamarin.Android ViewRenderer
- Xamarin.Forms ViewRenderer audio doesnt stop on homepage/backbutton
- Richfaces error page redirection with gatein, jboss 5.1.0 ga portlet bridge jars and my mistakes
- How to export view to the excel ASP.NET MVC
- FullCalendar viewRender: Append text in listDay-View
- ViewRenderer.SetNativeControl - The specified child already has a parent
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
I would just output the value in a JavaScript namespace inside a script tag in your view/controller rendering and then use that in your Angular app. Eg. output this:
Then you can just access the solution.vars.myVariable in your other JavaScript.