博客搭建遇到的問題(1)Angular與Ueditor

博客搭建遇到的問題

  • Angular不適用於Ueditor
  • angular Ajax方法發出請求時 服務器未能接受
  • 數據庫和php之間傳輸信息出現亂碼

Angular不適用於Ueditor

我們無法使用Angular腳本對Ueditor進行操作,這之後Ueditor官方提供了部分Ueditor功能的Angular拓展腳本
https://raw.githubusercontent.com/zqjimlove/angular-ueditor/master/dist/angular-ueditor.min.js
本地保存爲AngularUeditor.js
html文件首部對其進行引用
<script type="text/javascript" charset="utf-8" src="./utf8-php/angularUeditor.js"></script>

文件中完成getEditor()方法創建編輯器

<div class="ueditor" ng-model="content">
<script id="container_write" type="text/plain">
</script>
<script type="text/javascript">
var ue_write = UE.getEditor('container_write');
</script>
</div> 

依然無法正常使用
無法正常使用的Ueditor

發現問題來自於ng-show()屬性,去掉ng-show()方法便可以正常使用
所以我們的解決方法是angular中聲明函數UeditorInit()
在函數中我們調用APIgetEditor()來生成編輯器

出現ng-click無法處理UeditorInit()的問題

初始化編輯器的元素是:
<li class="lis"><a class="lia" href="#projects" ng-click="element = 4">添加項目</a></li>
我們添加事件函數ueditorInit()爲
<li class="lis"><a class="lia" href="#projects" ng-click="element = 4;ueditorInit()">添加項目</a></li>
運行後無法正常調用ueditorInit()函數
把分號換成逗號也不行

在菜鳥教程的演示demo裏嘗試ng-click事件調用函數並賦值
<button ng-click="toggle();firstName='hello'">隱藏/顯示</button>
<p ng-hide="myVar">
名: <input type=text ng-model="firstName"><br>
姓: <input type=text ng-model="lastName"><br><br>
姓名: {{firstName + " " + lastName}}
</p>

是可以的。

嘗試將angular控制器的初始化放到html的後面
依舊不行。

原來是angular初始化的ng-controller寫成了ng-control

Ueditor的正確調用
媽賣批

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章