1

I'm passing dictionary to my view and I'm using razor to pass it to JS.

My Code :

var data = []; 
@foreach(var tmp in Model){  
<text> data.push([ @tmp.Key,@tmp.Value]); </text>
}

My problem is that the code after it won't work. What am I missing out?

1
  • how does it look like in dev tools? I mean the output. Commented Oct 5, 2013 at 22:03

1 Answer 1

1

You might need the quotes around the values.

<text>data.push(["@tmp.Key","@tmp.Value"]);</text>

Take a look at the actual source (right click view source), and see if it's valid javascript or not.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.