1

fyi: please do not update the english for this question, because if you do I dont have enough points to approve it and I'll be stuck there for ever. I promise we'll improve the english once I solve the issue.

using angular ui.router, providing state for this view.

$stateProvider
    .state('tweets', { // */*/*/*/   new 
        url: '/tweets',
        templateUrl: '/tweets.html',
        controller: 'tweetCtrl'
    })

Controller

App.controller('tweetCtrl', ['$scope', '$http',
    function($scope, $http) {

        $scope.tweetArr; 

        get_tweets = function(id) {
            console.log('  === callign get tweets');
            // o.trends.length = 0
            console.log(' ~~~~~~~~~ calling  tweets with id  line  94 ~~~~~~~~~~~~  id= ', id);
            return $http.get('/tweets/' + id).success(function(record) {
                console.log(' >>>>>> tweets 95 = ', record.tweetArr);
                $scope.tweetArr = record.tweetArr; 
            });
        };
        get_tweets('GleePremiere'); 



    }
]);

Routes in Express4.

router.get('/tweets/:name', function (req, res, next) {

    Trend.findOne({ tName: '#GleePremiere' }, function(err, record) {
          if (err) {
            console.log(err);
            return next(err);
        }
        res.json(record);
    });

});

tweets.html

<div class="container">
    <h2>Tweet tweets.html</h2>

    <ul>
        <li ng-repeat="link in tweetArr">
            <blockquote class="twitter-tweet" lang="en">
                <a href={{link}} >Jan, 2015</a>
             </blockquote>  
        </li>
    </ul>

</div>

In the index.html page i.e the main view for angular app I'm also loading the script required by twitter to display the tweets.

<script src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>    

In the log it does grabs the links from the database , here's a screenshot of browser console.

enter image description here

view in browser:

enter image description here

Here's the expected output, but for similar code it doesn't show the list of tweets in my code within the partial.

==================================

Now I pasted the same code within my angular app, still I didnt get desired outpu.

potatoNews.controller('tweetCtrl', ['$scope', '$http',
    function($scope, $http) {

$scope.tweets = ["https://twitter.com/23243F/status/553762212981252096", "https://twitter.com/23243F/status/553762208791154688", "https://twitter.com/23243F/status/553762208287821824", "https://twitter.com/23243F/status/553762206987616257", "https://twitter.com/23243F/status/553762204580052992", "https://twitter.com/23243F/status/553762201992192000", "https://twitter.com/23243F/status/553762199123296257", "https://twitter.com/23243F/status/553762189803143168", "https://twitter.com/23243F/status/553762189526315008", "https://twitter.com/23243F/status/553762189497360384"]


    }
]);

tweets.html

<h2>Tweet tweets.html</h2>

<div ng-app ng-controller="tweetCtrl">
    <ul>
        <hr>
        <li ng-repeat="country in tweets">
            <blockquote class="twitter-tweet" lang="en">{{country}} <a href=" {{country}}">January 9, 2015</a>

            </blockquote>
        </li>
    </ul>
</div>
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>
JP.
  • 1,035
  • 2
  • 17
  • 39

0 Answers0