Javascript AngularJS函数的WYSIWYG短代码
我有一个自定义的WordPress短代码,当在WYSIWYG中使用时,它会返回一组带有角度函数的html 下面是我试图做的一个例子 短代码:Javascript AngularJS函数的WYSIWYG短代码,javascript,angularjs,wordpress,angularjs-scope,Javascript,Angularjs,Wordpress,Angularjs Scope,我有一个自定义的WordPress短代码,当在WYSIWYG中使用时,它会返回一组带有角度函数的html 下面是我试图做的一个例子 短代码: add_shortcode('example', function($atts) { extract(shortcode_atts([ 'string' => 'This is default text' ], $atts)); ob_start(); ?> &l
add_shortcode('example', function($atts) {
extract(shortcode_atts([
'string' => 'This is default text'
], $atts));
ob_start();
?>
<div class="example-layout">
<div class="container">
<button ng-click="do_something('<?= $string; ?>')">
Click here
</button>
</div>
</div>
<?php
return ob_get_clean();
});
<div class="example-layout">
<div class="container">
<button ng-click="do_something('Override default string')">
Click here
</button>
</div>
</div>
$scope.do_something = function(string) {
alert(string);
};
角度函数:
add_shortcode('example', function($atts) {
extract(shortcode_atts([
'string' => 'This is default text'
], $atts));
ob_start();
?>
<div class="example-layout">
<div class="container">
<button ng-click="do_something('<?= $string; ?>')">
Click here
</button>
</div>
</div>
<?php
return ob_get_clean();
});
<div class="example-layout">
<div class="container">
<button ng-click="do_something('Override default string')">
Click here
</button>
</div>
</div>
$scope.do_something = function(string) {
alert(string);
};
这是行不通的,但我正在努力寻找一个合理的解决方案
任何帮助或建议都很好。试试这种方法
<div class="container" ng-controller="TodoCtrl">
<button ng-click="do_something('testClick')">CLICK ME</button>
</div>