Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9259685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:42:53+00:00 2026-06-18T12:42:53+00:00

I just started playing with AngularJS today and am stuck. Pardon the coffeescript and

  • 0

I just started playing with AngularJS today and am stuck. Pardon the coffeescript and haml.

# some-js-file.js.coffee
app.directive "sr", ->
  restrict: "C"
  replace: true
  transclude: true
  scope:
    serviceRequest: "@servReq"
  template: "<div>" + "<div class=\"name\">{{service_request}}</div>" + "<div class=\"body\" ng-transclude></div>" + "</div>"
  link: (scope, element, attrs) ->
    scope.$watch 'serviceRequest', (serviceRequest) ->
      console.log scope.serviceRequest, serviceRequest
    # cool stuff

# index.html.haml
# more cool stuff...
.row{'ng-repeat' => 'service_request in service_requests'}
  .sr{'serv-req' => '{{service_request}}'}
    {{service_request.description}}

The loop and basic template are displaying except that the {{service_request}} expression isn’t being evaluated – just blank.

You will notice that in the ‘link:’ section, I had to $watch the scope for the console.log to work – it wasn’t evaluating serviceRequest either. What’s going on?

Thanks!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T12:42:54+00:00Added an answer on June 18, 2026 at 12:42 pm

    If service_request is an object (as indicated by service_request.description on the last line), then you cannot pass it into the directive using interpolation ({{service_request}}) and attribute-based binding (@servReq).

    Instead, you want the actual JavaScript value to be passed through, so you’ll need to change your Haml to

    .sr{'serv-req' => 'service_request'}
    

    and upate your directive to use bi-directional binding based on the attribute

    scope:
      service_request: "=servReq"
    

    (You also need to underscore service_request here, because that’s how it’s used in the template.)

    It’s hard to really tell what you’re trying to do, but here’s a jsFiddle that demonstrates these changes: http://jsfiddle.net/BinaryMuse/Z7Bru/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just started playing around with threading today and I ran into something that
I just started playing with Django today and so far am finding it rather
I just started playing around with WPF today, and I couldn't find the datagridview
I just started playing with Google App Engine and Java. I've used Servlets in
I've just started playing with mongoose today after reading The Little MongoDB book. I'm
I've just started playing with Google App Engine using php via Quercus. I'm not
Just started playing with Android and I'm trying to create an app that has
I just started playing around with haml and I am trying to understand what
I've just started playing with Red5 and am developing an app using which users
I have just started playing around with django-pagination , which is included in some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.