-
Notifications
You must be signed in to change notification settings - Fork 377
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Binding error in article-list, comment and article-actions components. #5
Comments
The problem seems to be in the ArticleListCtrl 's constructor. The call to setListTo() is made with an undefined variable. Comment the line and the rest should work fine in Angular 1.5 (//this.setListTo(this.listConfig);) |
As a workaround I made a method outside of the constructor. There you have access to the bindings (like in the follow button component). canModify() {
if (this._User.current) {
return (this._User.current.username === this.article.author.username);
}
else {
return false;
}
} and remember to update your template: <span ng-show="$ctrl.canModify()"> |
I've been working https://thinkster.io/angularjs-es6-tutorial#compartmentalizing-page-functionality-into-components tutorial trying to prep myself to move to angular 2. I'm getting error TypeError: Cannot read property 'author' of undefined, which I think follows along with this issue. The article html populates with the article data before I try to add the canModify code above but does not once this step is added. This is my project if anyone wants to look and see if this just an error by me https://github.com/RawleJuglal/flow_news_app/tree/front_end 4/25/17 Edit: |
RawleJuglal, thank you for that! In package.json, I changed |
As @hht1230 said, Changing angular version from "^1.5.0-rc.2" to "~1.5.0" works perfectly and solves all the problem. Also @bstelljes solution to the problem has also been resolved with this change. Thanks guys for the solution. |
To be able to use angular "1.6" (keeping "^1.5.0-rc.2" in package.json) in the constructor wrap the validation inside "$onInit" (thanks @RawleJuglal ) this way: this.$onInit = () => {
// The users can only edit/delete this article if they are the author
if (User.current) {
this.canModify = (User.current.username === this.article.author.username);
} else {
this.canModify = false;
}
} |
Hi there, it seems that there is an issue with the article-list, comment and article-actions components. The binding values from the components are not accessible in the controllers. Any ideea of a solution?
The text was updated successfully, but these errors were encountered: