0

I'm trying to get the pageTitle to initialise to data.products[whichItem].date if condition is true or pageTitle = data.products[whichItem].valuetoday if condition is false is there an ng-directive more appropriate or is my syntax wrong

  <section ng-bind="(true) '{{pageTitle = data.products[whichItem].date | 
getYear}}' : '{{pageTitle = data.products[whichItem].valuetoday}}' " ></section>
2
  • notice the tagging. The angular-tag refers to angular 2 -> This is AngularJS, so should be tagged with angularjs ;) Commented Apr 14, 2017 at 16:05
  • The role of the template is to display data. Not to initialize variables. Initialize variables in your controller. Commented Apr 14, 2017 at 16:06

1 Answer 1

3

Do you want to print the pageTitle value or assign value to pageTitle.?

You can do those things in controller. ng-bind is only to print the value in page

$scope.setPageTitle(data,itemIndex){
$scope.pageTitle = <Condition> ? data.products[itemIndex].date : data.products[itemIndex].valuetoday;
}

Then if you want to print it. <section ng-bind='pageTitle'></section> use this.

Sign up to request clarification or add additional context in comments.

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.