ngSanitize显示新行\ n

时间:2014-01-28 19:48:33

标签: angularjs angularjs-directive

我应该用

显示一个帖子条目
<div data-ng-bind-html="post.body"></div>

但页面显示新行特殊字符

\n

你知道这很难看。

这是一个错误吗? 有没有办法避免它?

更新以显示我正在使用的代码:

(function(window, angular, undefined) {
    'use strict';
    angular.module('nodblog.api.post', ['restangular'])
        .provider('Post', function() {
            this.$get = function(Restangular) {
                function ngPost() {};
                ngPost.prototype.status = ['publish','draft'];
                ngPost.prototype.labels = {
                    frmCreateHeader:'Add New Post',
                    frmEditHeader:'Edit Post'
                };
                ngPost.prototype.posts = Restangular.all('post');
                ngPost.prototype.one = function(id) {
                    return Restangular.one('post', id).get();
                };
                ngPost.prototype.all = function() {
                    return this.posts.getList();
                };
                ngPost.prototype.store = function(data) {
                    return this.posts.post(data);
                };
                ngPost.prototype.copy = function(original) {
                    return  Restangular.copy(original);
                };
                return new ngPost;
            }
    })
})(window, angular);

// config block
$routeProvider
        .when('/', {
            templateUrl: '/default/views/index.html',
            resolve: {
                posts: function(Post){
                    return Post.all();
                }
            },
            controller: 'IndexCtrl'
        })

main app
.controller('IndexCtrl', function ($scope,posts) {
        $scope.posts = posts;
    })

0 个答案:

没有答案