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
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.
Comments