javascript - 是否可以只使用 AngularJS 的前端脚本?

标签 javascript angularjs

我看到有人谈论将后端语言(如 asp.net、php)与 AngularJS 一起使用。但是,他们只是通过创建 API 从 NodeJs 向其他后端语言发出 HTTP 请求。 AngularJS 或 NodeJs 本身已经是一种后端语言,我不认为自己开发 2 个后端 Web 应用程序只是为了使用 AngularJS。

是否有可能只让 AngularJS 生成的前端脚本在使用另一种后端语言的 Web 项目上运行,或者只是一个没有后端的简单项目(带有 JavaScript 版本 6 的 Html)或者使用 AngularJS 就像它一样是 ViewJs 吗?

问题是我想使用 ng-if, ng-for... 就像在 View 中我们使用 v-if , v-for... 并省略 Angularjs 路由和其他 NodeJs 内容。这样,当我运行该项目时,我不需要运行 NodeJs 或 Angular-cli。我的意思是只使用 AngularJS 模板。

我希望我和我的英语是清楚的。

最佳答案

AngularJS 是在浏览器中自编译的。无需 NodeJS 或任何后端编译。

<script src="//unpkg.com/angular/angular.js"></script>
<body ng-app>
    <input type="checkbox" ng-model="showMessage">ng-if = {{showMessage}}<br>
    <p ng-if="showMessage">
    See, no backend necessary. Ng-if was compiled in the browser.
    </p>
</body>


On angularjs.org they say "This site and all of its contents are referring to AngularJS (version 1.x), if you are looking for the latest Angular, please visit angular.io.". So, what does that mean?

友情提示: 1

Angular 1.x  == AngularJS
Angular 2+   == Angular

有关详细信息,请参阅

关于javascript - 是否可以只使用 AngularJS 的前端脚本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56963077/

相关文章:

javascript - 提供给 `selectRow` 的 `string` 类型的无效 Prop `BootstrapTable`,预期为 `object`

javascript - AngularJS 数据绑定(bind) - 观察周期未触发

javascript - 如何以多种方式使 Angular ng-switch 动画(进入/离开)?

javascript - Microsoft Online Auth 没有 'Access-Control-Allow-Origin' header

javascript - 使用 JQuery onfocusout 或 onblur 事件时如何重新聚焦于输入元素?

javascript - 将容器 DIV 叠加在其自己的子项上

javascript - 重置 React 中控件的默认值

Twig 中的 AngularJS 组件

javascript - 如何在 Ionic 应用程序中以正确的方式准备好设备?

javascript - 我在停止表单提交事件时遇到问题