- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一些相同类别的文章,我的路由如下:
app.config(function($routeProvider) {
$routeProvider
.when('/chapter/:title', {
templateUrl: 'article.html',
controller: 'article'
});
});
article.html:
<h1>{{title}}</h1>
<p>{{content}}</p>
<button>Editor</button>
但是现在我想获取从本章每篇文章到编辑器版本的路由以更改内容。这个编辑器版本可能如下所示:
editor_article.html:
<input type="text" value="{{title}}">
<textarea>{{content}}</textarea>
那么将文章的按钮路由到 editor_article.html-template 并使用相同的数据加载它的最佳方法是什么?
最佳答案
这里没有“最佳方法”,这完全取决于您的具体情况。
所有最终用户都对此具有平等的访问权限(或者换句话说,任何可以打开开发控制台的人都应该被允许访问此页面)吗?
如果没有,您需要在加载 SPA 的大部分代码之前解决登录问题。
如果登录不是问题,或者已经解决了,为什么需要单独的路由?
您需要在浏览器中单独缓存这些页面吗?
除此之外还有其他考虑吗?
完全合理的问题;从艺术的 Angular 来看,也许您希望页面转换能够与您更改路由时的其他转换相匹配,或者您依赖于routeParams来实现我们不知道的某些逻辑。
但是,除了上述所有内容之外,您很可能只需一个按钮和几个带有指令的 ng-if 语句。
<body >
<main ng-view></main>
</body>
<!-- template -->
<section >
<button
ng-click="article.toggleMode()">{{
article.editMode ? "View": "Edit"
}}</button>
<article-view
content="article.content"
ng-if="!article.editMode"
></article-view>
<article-edit
content="article.content"
onsave="article.save(content)"
ng-if="article.editMode"
></article-edit>
</section>
使用指令定义两个模板,在上面的示例中使用 controllerAs:"article"
。
即使这样也可能会让事情变得复杂。
关于javascript - Angular .js : routing to an editor-version of the current article,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30114726/
我最近在浏览 https://github.com/ory/editor/blob/master/packages/ui/src/Trash/index.js#L89 发现了一种我不明白的论点。完整代
我已经在 D 中编程了一段时间 (http://www.digitalmars.com/d/)现在。比起 Java,我更喜欢它,因为它更快。但是,我还没有找到支持代码完成和调试(Step-Over、S
如何使用 Ace 编辑器执行以下操作。 用户输入“@”字符 弹出自动完成 用户从下拉列表中进行选择 既然已经做出选择,“@”就会被删除 我基本上希望 @ 作为自动完成的触发器,但我不希望它在之后徘徊。
您可以使用 monaco.languages.typescript.typescriptDefaults.addExtraLib 添加您在 TypeScript 解析期间可能需要的任何 *.d.ts
我们公司正在使用 swagger 来记录他们的 API,目前有几个开发人员正在他们的 PC 上使用在线 swagger 编辑器。 我想将这部分设计过程移到我们的标准开发环境中,该环境位于没有互联网访问
我正在 monaco-editor 中定义新语言.我希望它会自动突出显示匹配的括号和圆括号,因为默认情况下 matchBrackets选项是真的。 我还需要做些什么吗? 示例代码: 看 this pa
我正在尝试在我目前正在开发的项目中使用 Microsoft 的 Monaco Editor。我查看了文档,发现您可以使用自定义代码完成和语法突出显示来设置自定义语言,但我找不到任何关于如何向自定义语言
我非常喜欢 Notepad++ 中的一个功能,按 Alt并用鼠标选择启用矩形选择,就像桌面上的选择...想不出一个合适的术语,也许rectangular selection或 vertical sel
有没有办法将插入符号位置作为源代码字符串中的索引? 我知道我可以获得位置,它会给我一个包含行和列的对象,但是有没有办法获取或将行 + 列转换为字符串字符索引? 例如,如果我有: using Syste
我一直在用 Balsamiq创建模型。我使用的是试用版,所以我将所有屏幕都放在一个模型中,而不是多个文件中。我想将这些模型的导出发送给我的团队,以便他们可以对其进行评论。他们需要能够轻松地添加箭头、标
默认为 CRLF。我想在处理 BASH 脚本时将其更改为 LF。请帮忙。 我已经浏览了文档,但找不到任何解决方案或示例。 最佳答案 //https://github.com/Microsoft/vsc
将任何回调附加到 editor.onDidChangeModelContent(event) 到 Monaco 实例后,如何删除(或取消绑定(bind))此函数? 例如,ACE 编辑器提供了 func
我已经将编辑器设置为只读,它是只读的,但它显示了一个光标。我想以编程方式隐藏光标(除非以编程方式,否则不通过样式)。 最佳答案 以下是建议答案的作用,用于视觉比较: 这是以前的样子: 添加: edit
我有一个用例,用户单击按钮在当前光标位置插入文本。 但是在使用 session.insert(cursorPosition, textToAdd) 插入文本之后, 光标位置移动到第一个字符。 我尝试使
我正在使用 monaco-editor 库为自定义编程语言实现网络编辑器。 我已经实现了一个 CompletionItemProvider 来提供自定义完成建议。 总的来说效果很好。但是,在执行片段时
我正在使用 monaco-editor,我想包含来自多个文件的建议。我不确定最好的方法是什么,但基本上,我希望当我在 file2.js 中导出一些函数时,能够从建议中的另一个 file1.js 访问它
我正在为我的应用程序添加 TypeScript 支持 Data-Forge Notebook . 它是一个笔记本风格的 JavaScript 应用程序。当我在代码单元格中使用“等待”关键字时,摩纳哥将
Monaco Editor 中是否有用于文本选择的事件? 我需要响应用户在编辑器中选择部分代码? 有没有更好的解决方案来使用计时器来获取选择范围? 文件似乎没有提到它。 最佳答案 您可以使用 onDi
我正在使用 monaco-editor 来显示本地代码文件的内容,这些文件可能是用各种语言编写的,所以我想知道如何根据文件的扩展名或文件的第一行动态设置/更改 monaco 编辑器的语言没有扩展名(如
在 Monaco Editor 中,使用标准初始化,例如: monaco.editor.create(document.getElementById("container"), { value
我是一名优秀的程序员,十分优秀!