将 angular-trix 添加到 angularjs firebase 应用

Add angular-trix to angularjs firebase app

我正在使用 angular 和 firebase 制作应用程序。我想实现 angular-trix 编辑器,以便用户可以 post 自己的文章。但是我不知道如何整合angular-trix。我包含了 js 文件并在 app.js 中注入了 'angularTrix'。 var app = angular.module('myApp', ['ngRoute', 'ui.bootstrap', 'ngAnimate', 'firebase', 'ngSanitize','angularTrix']); 这是我的 html 页面。

<div>
<trix-editor ng-model="trix" angular-trix></trix-editor>
<button ng-click="save()">Save!</button></div>

这是控制器

app.controller('profileCtrl', ['$scope', "$routeParams", "$firebaseObject", "$sce", "Auth", function($scope, $firebaseObject, $routeParams, $rootScope, Auth, $sce) {
// Demo controller
console.log('In ctrl');

$scope.trix = '<p>Hello</p>';
$scope.save = function() {
  alert($scope.trix);
};}]);

我不知道我必须在控制器中包含什么。我希望当用户按下提交按钮时,它应该提取 HTML 并将其保存到 firebase。

我知道如何在 firebase 中保存数据,但不知道如何从 AngularTrix 中提取 HTML。

一段控制器代码会很有帮助。

内部 html 存储在您通过 ng-model 属性传递给编辑器的模型中,如下所示:

<trix-editor angular-trix ng-model="foo"></trix-editor>

在这里,foo 会有您的标记:

angular.module('trixDemo', ['angularTrix']).controller('trixDemoCtrl',   function($scope) {
  $scope.foo = '<div>Hello world!</div>';
});

Demo