Last active
August 29, 2015 14:09
-
-
Save yoren/56da3883bcdb0a8f2e6b to your computer and use it in GitHub Desktop.
Best Practice to sanitize HTML in AngularJS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>{{post.title}}</h1> | |
<div ng-bind-html="post.content"></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function my_scripts() { | |
wp_register_script( | |
'angularjs', | |
get_stylesheet_directory_uri() . '/bower_components/angular/angular.min.js' | |
); | |
wp_register_script( | |
'angularjs-route', | |
get_stylesheet_directory_uri() . '/bower_components/angular-route/angular-route.min.js' | |
); | |
wp_register_script( | |
'angularjs-sanitize', | |
get_stylesheet_directory_uri() . '/bower_components/angular-sanitize/angular-sanitize.min.js' | |
); | |
wp_enqueue_script( | |
'my-scripts', | |
get_stylesheet_directory_uri() . '/js/scripts.js', | |
array( 'angularjs', 'angularjs-route', 'angularjs-sanitize' ) | |
); | |
wp_localize_script( | |
'my-scripts', | |
'myLocalized', | |
array( | |
'partials' => trailingslashit( get_template_directory_uri() ) . 'partials/' | |
) | |
); | |
} | |
add_action( 'wp_enqueue_scripts', 'my_scripts' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('app', ['ngRoute', 'ngSanitize']) | |
// ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment