1

Here is a little question, I have jade variable so i want to assign that jade variable to angular bind.

But it's return Error

Here is my Jade

- var editor = false // my variable 
.content
    .title Title

     // that i want to assign 
    - editor = {{editormode}} // $scope.editormode = true || false return
    if editor
       .title-edit
1
  • Jade compiles to HTML and the HTML will use as template in angular. How should Jade know your scope? Do you render the templates on runtime? How is your setup? More infos please. Commented May 12, 2016 at 8:49

3 Answers 3

2

You can't use Angular scope variables in Jade control expressions. Jade compiles templates into resulting HTML used by Angular, not otherway around.

In your case you probably want ngIf directive:

- var editor = false // my variable 
.content
    .title Title 
    .title-edit(ng-if="editormode")
Sign up to request clarification or add additional context in comments.

Comments

1

Jade is a server-side engine which has the sole purpose of generating an HTML from a template, which Angular has no interaction with. Angular is a client-side framework which works with the HTML received from the server. A way to achieve what you want is to store your editor variable into an <input type="hidden"> and then access its value via Angular.

Comments

0

I've never used jade and angular together before but if you are successfully passing your 'editormode' variable to the jade template then the following will work:

.content
  .title Title

  if editormode
     .title-edit

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.