大家好我想把ckeditor中的文本传递给我的代码angularjs但总是未定义 这是html
<textarea name="editor1" ng-model="editor1" id="editor1" rows="10" cols="80">
<button type="submit" class="button expand success" ng-click="insertArticle()">Save</button>
这是angularjs
$scope.insertArticle = function(){
$scope.dataInsert = {
'editor1':$scope.editor1
};
$http.post('script_php/insert/insert_article.php',$scope.dataInsert)
.success(function(data,status,header,config){
if (status==200) {
console.log('GOOD');
console.log($scope.dataInsert);
} else {
console.log('not good');
}
})
}
这里的问题如何绑定我的textarea(CKEDITOR)的数据我跳了解你,谢谢你。
答案 0 :(得分:0)
正如您在此代码段中看到的,绑定实际上正在运行:
function MyController($scope, $http) {
$scope.insertArticle = function(){
alert($scope.editor1);
};
}
&#13;
<div ng-app ng-controller="MyController">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<textarea name="editor1" ng-model="editor1" id="editor1" rows="10" cols="80"></textarea>
<button type="submit" class="button expand success" ng-click="insertArticle()">Save</button>
</div>
&#13;
我认为你的问题是由于编码错误而导致你没有在PHP端得到帖子的正文。你应该明确地将编码设置为x-www-form-urlencoded,特别是如果你的后端在PHP中:
$http.post('script_php/insert/insert_article.php',$.param($scope.dataInsert), {headers: {'Content-Type': 'application/x-www-form-urlencoded'}})