- var app = angular.module('app', []);
- app.controller('ctrler', ['$scope', '$http', function ($scope, $http) {
- $scope.magic = function () {
- thepost = $http.post('api/', {action: "hello"}).
- success( function (data) {
- $scope.tops = data;
- }).
- error( function (data) {
- console.log('fail');
- })
- }
- }]);
- app.directive('toplist', function ($compile) {
- return {
- restrict: 'A',
- replace: true,
- link: function ($scope, ele, attrs) {
- $scope.poasts = ele;
- $scope.$watch( function (qdata) {
- ele.html($compile(angular.element("<div ng-repeat='p in tops'>{{ p.topic }}</div>"))($scope));
- })
- }
- }
- })
SHARE
TWEET
Untitled
a guest
Nov 1st, 2014
7
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
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.

