angular应用程序在重新加载/提交后从wordpress中删除输入表单UNWILLING



我有一个表单:

<table class="widefat" ng-app="myApp" ng-controller="MyCtrl">
<tr>
<td><label for="name_pokemon"><?php _e( "Name", "cpt" ); ?></label></td>
<td><input id="name_pokemon_val" maxlength="{{a1Max}}" name="name_pokemon" type="text" ng-model="a1" ng-change="update()" value="<?php echo esc_textarea( get_post_meta($post->ID, 'name_pokemon', true) ); ?>" placeholder="<?php esc_attr_e( 'Name', 'cpt' ); ?>"></td>
<td>Length: {{a1.length}} Remaining: {{remainingA}}</td>
</tr></table>

我的脚本:

<script>
var myApp = angular.module('myApp',[]);
function MyCtrl($scope) {
$scope.a1='';

var maxA = 21;

$scope.update = function()  {
$scope.remainingA = maxA - ($scope.a1.length);
$scope.a1Max = maxA;

}
$scope.update();}</script>

现在我有一个问题,在我提交自定义文章类型后,它会重置输入数据。

我该怎么解决?

感谢您帮助

在这里发现了类似的问题

棱角分明的应用程序只显示应用程序的值。。。我用wordpress 的值初始化应用程序的var来修复它

现在看起来是这样的:

$scope.a1='<?php echo esc_textarea( get_post_meta($post->ID, 'name_pokemon', true) ); ?>'; 
$scope.a2='<?php echo esc_textarea( get_post_meta($post->ID, 'code_card_pokemon', true) ); ?>';
$scope.b1='<?php echo esc_textarea( get_post_meta($post->ID, 'lang_pokemon', true) ); ?>';
$scope.b2='<?php echo esc_textarea( get_post_meta($post->ID, 'code_pokemon', true) ); ?>';
$scope.c1='<?php echo esc_textarea( get_post_meta($post->ID, 'setname_pokemon', true) ); ?>';

在初始化范围后,它工作得很好。

我希望我能帮助

最新更新