2015-09-01 5 views
-5

Бруса впрыснуть комментарий услугу в комментарии директиву получать errorComment сервис не найденслужбы Вводит в директиву

// Code goes here 

var noBlogApp = angular.module("noBlogApp", ['ngRoute', 'ngSanitize', 'commentSystem']); 


noBlogApp.config(['routeProvider', function(routeProvider) { 
    routeProvider.null when('/', { 
    controller: "noBlogController", null templateUrl: 'post.html', 

    }).when('/post/:id', { 
    controller: 'singlePostController', 
    templateUrl: 'singlepost.html', 

    }); 
}]); 


noBlogApp.service('commentService', ['http', function(http) { 
    http.get('js/assureBlog.JSON').success(function(data) { 

    this.getComment = function(id) { 
     scope.comment = data[id]; 
     return scope.comment; 
    } 

    var addComment = function() { 
    } 

    var addReply = function() { 
    } 

    var deleteComment = function() { 

    } 

    var deleteReply = function() { 

    } 

    }); 

}]); 

noBlogApp.controller('noBlogController', ['scope', 'http', function(scope, http) { 
    scope.message = "hello"; 
    http.get('js/assureBlog.JSON').success(function(data) { 
    scope.post = data; 

    }); 

}]); 
nullnoBlogApp.controller('singlePostController', ['scope', 'http', 'routeParams', 'commentService', function(scope, http, routeParams, commentService) { 
    null http.get('js/assureBlog.JSON').success(function(data) { 
    scope.post = data[routeParams.id]; 

    }); 
    scope.commentService = commentService; 
    console.log("this is the" + commentService) null 
}]); 

noBlogApp.directive('comments', ["commentService", function(commentService) { 

    return { 
    scope: { 
     id: '@' 
     }, 
     template: id: { 
     { 
      id 
     } 
     } 
    link: function(scope, element, attrs, commentService) { 
     console.log(scope.commentService); 
    } 

    }; 

}]); 
+4

Слишком много вещей, чтобы даже попытаться отформатировать его правильно. –

ответ

0

Хотя вопрос плохо отформатирован, это выглядит как ваш вопрос заключается в следующем:

link:function(scope,element,attrs,commentService)

Удалить комментарийСлужба от функции связи. Вы уже добавили зависимость к конструкции директивы.

Смежные вопросы