最近Webアプリケーションおよびjavascriptを勉強し始めました。
今回、YeomanのMEANスタックであるAngularJS Full-Stack generatorを使って
Teitter風のWebアプリケーションを作成しようとしています。
参考にしているサイトはこちらです
client/app/main/main.controller.jsで自分の投稿を判定する関数を追加し、
main.htmlの中で呼び出したいのですが、うまく呼び出せません。
- main.controller.js
javascript
1angular.module('testApp') 2.controller('MainController', function ($scope, $http, socket, Auth) { 3 $scope.isLoggedIn = Auth.isLoggedIn; 4 $scope.getCurrentUser = Auth.getCurrentUser; 5 $scope.isMyTweet = function(thing){ 6 return Auth.isLoggedIn() && thing.user && thing.user._id===Auth.getCurrentUser()._id; 7 }; 8 }); 9})();
- main.html
html
1<div class="row"> 2 <div ng-repeat="thing in main.awesomeThings"> 3 {{thing.user.name}} - {{thing.name}} ({{thing.createdAt}}) 4 <button type="button" class="close" ng-if="isMyTweet(thing)" ng-click="main.deleteThing(thing)">×</button> 5 </div> 6</div>
上記の記述で、ng-if="isMyTweet(thing)"の部分が正しく動作していない状況です。
どなたか上記コードの問題点をご教授頂きたいです。
宜しくお願い致します。
回答3件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/04/22 14:24