Skip to content

Instantly share code, notes, and snippets.

Last active April 25, 2018 14:37
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Pass data from MVC to Angular 2


<my-angular-app appID="@Model.AppId">Loading...</my-angular-app> 


//function to get the attribute value.
export function getAttribute(app: string, attributeName: string) {
  return document.getElementsByTagName(app)[0].getAttribute(attributeName);


import { getAttribute } from './util'
export class AppComponent implements OnInit {
    let appId = getAttribute("my-angular-app", "appID")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment