1

I'm trying to setup a basic angular app to test some translation logic and somehow I can't get my data to display on the frontend.

Here's my html:

<div ng-app="testApp">
  <div ng-controller="myController">
    <p >{{ title }}</p>
    <p >{{ text }}</p>
  </div>
</div>

And my JS:

var testApp = angular.module('testApp', []);

testApp.controller('myController', function ($scope) {
  $scope.data = {
    title: 'PAGE_TITLE',
    text :'some random page text'
  };
});

I've created a codepen, added reset.css, jQuery and AngularJS as depedencies, but can't figure out what I'm doing wrong.

Any help appreciated.

3
  • 1
    It should be {{data.title}} & {{data.text}} Commented Jan 7, 2016 at 8:59
  • 1
    ugh. thx a lot, write it up as an answer and I'll accept it Commented Jan 7, 2016 at 9:00
  • i added an answer :) Commented Jan 7, 2016 at 9:03

3 Answers 3

4

You should bind those property from data object as title and text belongs to that data object.

Markup

<div ng-app="testApp">
  <div ng-controller="myController">
    <p >{{ data.title }}</p>
    <p >{{ data.text }}</p>
  </div>
</div>
Sign up to request clarification or add additional context in comments.

Comments

0

You should always need to write the scope object whose property you need to print.

<div ng-app="testApp">
  <div ng-controller="myController">
    <p >{{ data.title }}</p>
    <p >{{ data.text }}</p>
  </div>
</div>

Try like this.

Comments

0

it should be {{data.title}} & {{data.text}}

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.