Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使字段显示为文本而不在HTML代码中重复_Javascript_Jquery_Angularjs_Fullcalendar_Fullcalendar Scheduler - Fatal编程技术网

Javascript 如何使字段显示为文本而不在HTML代码中重复

Javascript 如何使字段显示为文本而不在HTML代码中重复,javascript,jquery,angularjs,fullcalendar,fullcalendar-scheduler,Javascript,Jquery,Angularjs,Fullcalendar,Fullcalendar Scheduler,我有一个这样的数据结构: books = [ { id: 'id1', content: { name: '<p><span>name</span><span>1</span></p>', price: 'price1',

我有一个这样的数据结构:

books = [
            {
                id: 'id1',
                content: {
                    name: '<p><span>name</span><span>1</span></p>',
                    price: 'price1',
                    date: 'd1'
                }
            },
            {
                id: 'id2',
                content: {
                    name: '<p><span>name</span><span>2</span></p>',
                    price: 'price2',
                    date: 'd2'
                }
            },
            {
                id: 'id3',
                content: {
                    name: '<p><span>name</span><span>3</span></p>',
                    price: 'price3',
                    date: 'd3'
                }
            }
        ]
如何在没有HTML的情况下使名称字段显示在外部事件框中? 我尝试了ng bind html unsafe=book.content['name'],但它不起作用

<body ng-controller="MainCtrl">
<div id='external-events'>
  <h4 >Draggable books</h4>

     <li ng-repeat="book in books track by $index"  
             id="book.id">
          <ul class="fc-event" data-drag="true"  data-jqyoui-options="{revert: 'invalid'}" jqyoui-draggable="{index {{$index}},placeholder:true,animate:true}">
            <li ng-bind-html-unsafe="book.content['name']"> {{book.content['name']}}</li>
            <li>{{book.content['price']}}</li>
            <li>{{book.content['date']}}<br></li>
           </ul>
      </a>
  </div>
<div id='calendar-container'>
  <div id='calendar'></div>
</div>
</body>
下面是为此目的创建的代码笔

非常感谢。

从li元素中删除{{book.content['name']}}。您有一个属性指令ng bind html unsafe,它可以实现以下功能:

 <li ng-bind-html="book.content['name']"></li>

fiddle:

谢谢Danil,但我应用了你的想法,但它也删除了名称的显示,这意味着我将只显示名称的两个字段“价格”和“日期”。非常感谢Danil。
  $scope.books.forEach(function(book) {
    book.content.name = $sce.trustAsHtml(book.content.name);
  })