Directives scope variable does not work in Jade

0xmtn

I know the title is bad but the situation itself is weird enough to have this title. So here is my jade file - template:

img.picture(ng-show='user.info.profilePicUrl', ng-src='{{user.info.profilePictureUrl}}')
img.picture(ng-show="!user.info.profilePicUrl", ng-src="dummyuser.png")
.basicinfo
  h1.fullname
    a(href='profile/{{user.info.username}}') {{user.info.fullName}}
  p.description {{user.info.bio}}
   span.additional
    a.website(href='{{user.info.website}}') {{user.info.website}}
    a.location(href='#') {{user.info.location}}
.follow
  .count {{user.followedBy.length}} Followers
  follow(to-follow-username="user.info.username")

In the directive:

scope: {
  user: "="
},
controller: function($scope){                                                                                      
    var request = $http({                                                                                            
      method: "get",                                                                                                 
      url: "/users/" + $scope.user.userID + "/getInfo",                                                              
    });                                                                                                              

    request.success(function(data, status, headers, config){                                                         
      $scope.user.info = data;                                                                                       
      console.log($scope.user);                                                                                      
    });                                                                                                              

    request.error(function(data, status, headers, config){                                                           
      console.log("Status");                                                                                         
      console.log(status);                                                                                           
    });                                                                                                              
  },       
templateUrl: "/templates/follower"

So here is problem: When I open the page that contains this template and directives, the user is passed to jade above, and every line of it parses the data from user, except profilePicUrl, and user.info.username. The user.info.username work fine in the line a(href='profile/{{user.info.username}}') {{user.info.fullName}}, but it doesn't work - comes as undefined - in the line follow(to-follow-username="user.info.username").

img.picture(ng-show='user.info.profilePicUrl', ng-src='{{user.info.profilePictureUrl}}')
img.picture(ng-show="!user.info.profilePicUrl", ng-src="dummyuser.png")
.basicinfo
  h1.fullname
    a(href='profile/{{user.info.username}}') {{user.info.fullName}} //The username is actual username - Works Here
  p.description {{user.info.bio}}
   span.additional
    a.website(href='{{user.info.website}}') {{user.info.website}}
    a.location(href='#') {{user.info.location}}
.follow
  .count {{user.followedBy.length}} Followers
  follow(to-follow-username="user.info.username") //Doesn't work here
KyleK

Do not make the HTTP cal synchronous but re-apply the scope modifications on success:

request.success(function(data, status, headers, config){
  $scope.$apply(function () {
    $scope.user.info = data;
  });
}); 

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Why does printing a variable in global scope work, but modifying it does not?

From Dev

Why does printing a variable in global scope work, but modifying it does not?

From Dev

meteor Jade iteration does not work

From Dev

How does one preserve scope with nested directives?

From Dev

How does one preserve scope with nested directives?

From Dev

Using a local variable outside of its declaring scope; why does this work?

From Dev

How does variable scope work within the Mocha test framework?

From Dev

Prolog: how does variable instantiating work, what is the scope of local variables

From Dev

Prolog: how does variable instantiating work, what is the scope of local variables

From Dev

Scope in directives

From Dev

Scope in directives

From Dev

Angular $scope does not work

From Dev

Angular $scope does not work

From Dev

Why does it work with $scope but not with `this`?

From Dev

Why --watch Jade option does not work?

From Dev

Why does this jade template not work with commenting?

From Dev

Meteor JS Jade template does not work as expected

From Dev

Jade Syntax does not work with pug : Node Js

From Dev

problems with the scope variable over communication between the directives in angularjs

From Dev

How does scope work in Io?

From Dev

How does scope work in Ruby?

From Dev

Why does the scope work like this?

From Dev

Scope inheritance for angular directives

From Dev

controllerAs with directives and isolated scope

From Dev

Scope Isolation & nested directives

From Dev

AngularJS : directives and scope

From Dev

Isolated scope for directives

From Dev

angular scope in controllers + directives

From Dev

AngularJs scope reference with directives

Related Related

HotTag

Archive