我的应用没有显示文字

时间:2016-11-21 19:53:10

标签: javascript angularjs

我的应用很简单:用户输入文本,文本保存在数据库中并显示。问题是它显示为空白。在图片中看到每个点应该有一个文本。

dots instead of text

主要角度控制器:

myApp.controller('meetupsController', ['$scope', '$resource', function ($scope, $resource) {
  var Meetup = $resource('/api/meetups');

  Meetup.query(function (results) {
    $scope.meetups = results;
  });

  $scope.meetups = []

  $scope.createMeetup = function () {
    var meetup = new Meetup();
    meetup.name = $scope.meetupName;
    meetup.$save(function (result) {
      $scope.meetups.push(result);
      $scope.meetupName = '';
    });
  }
}]);

html partial:

<!--main.html-->
<body>
  <div id='main' ng-controller="loginController">
      <form ng-Submit="post()">
         <input required type="text" placeholder="Your name" ng-model="newPost.created_by" /> 
         <textarea required maxlength="200" rows="3" placeholder="Say something" ng-model="newPost.text"></textarea>
         <input class="button" type="submit" value="Chirp!" />
      </form>
      <div id="post-stream">
         <h4>Chirp Feed</h4>
         <div class='post' ng-repeat="post in posts | orderBy:'created_at':true" ng-class-odd="'odd'" ng-class-even="'even'">
             <p>{{post.created_by}} says {{post.text}} at {{post.created_at}}</p>
         </div>
         <div ng-controller="logoutController">
           <a ng-click='logout()' class="btn btn-default">Logout</a>
         </div>
          <div ng-controller="logoutController">
           <a ng-click='gotoregister()' class="btn btn-default">register</a>
         </div>
      </div>
  </div>
  <div ng-controller="meetupsController">
     <h1>There are {{meetups.length}} meetups</h1>
     <ul>
     <li ng-repeat="meetup in meetups">
       {{meetup.name}}
     </li>
     </ul>
    <form ng-submit="createMeetup()">
       <input type="text" placeholder="Meetup name" ng-model="meetupName"></input>
       <button type="submit">Add</button>
    </form> 
  </div>
</body>

API代码:

var Meetup = require('./models/meetup');

module.exports.create = function (req, res) {
  var meetup = new Meetup(req.body);
  meetup.save(function (err, result) {
    res.json(result);
  });
}

module.exports.list = function (req, res) {
  Meetup.find({}, function (err, results) {
    res.json(results);

  });
}

0 个答案:

没有答案