javascript - Make html preview of blog post in Angular.js using ng-bind-html -


i have list of posts loads perfect, entire content of each post. html post content string in database column. want create read more link @ position desire , show post preview in list (a part of html content). accomplish write comment inside posts it´s point cut content in order preview.

how can manipulate content before ng-bind-html loads it? need detect first comment , clean content html document. i´m making tests in jquery know how on angular way.

i think filter inside ng-bind-html expression can work. don´t how manipulate html string inside filter. manipulate jquery syntax because need remove lot of tags , stuff.

<script>     $(function() {         var com = $("*")            .contents()            .filter(function(){ return this.nodetype == 8;})            .first();         com.nextall().remove();     }); </script> 

thanks

you can add function executed during ng-bind-html , access string using sanitise service $sce. see details on $sanitise service.

inside ng-bind-html can manipulate dom using jqlite , native javascript (by using $document wrapper). if manipulations complex, i'd use jquery directly. have include before angular in index.html , use angular.element instead of $


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -