SHARE
TWEET

Untitled

a guest Nov 1st, 2014 7 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var app = angular.module('app', []);
  2. app.controller('ctrler', ['$scope', '$http', function ($scope, $http) {
  3.         $scope.magic = function () {
  4.                 thepost = $http.post('api/', {action: "hello"}).
  5.                 success( function (data) {
  6.                         $scope.tops = data;
  7.                 }).
  8.                 error( function (data) {
  9.                         console.log('fail');
  10.                 })
  11.         }
  12. }]);
  13. app.directive('toplist', function ($compile) {
  14.         return {
  15.                 restrict: 'A',
  16.                 replace: true,
  17.                 link: function ($scope, ele, attrs) {
  18.                                 $scope.poasts = ele;
  19.                                 $scope.$watch( function (qdata) {
  20.                                         ele.html($compile(angular.element("<div ng-repeat='p in tops'>{{ p.topic }}</div>"))($scope));
  21.                                 })
  22.                 }
  23.         }
  24. })
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top