GVKun编程网logo

如何正确刷新在VS 2015 Web开发环境中运行的AngularJS SPA(vs怎么刷新)

8

本文将介绍如何正确刷新在VS2015Web开发环境中运行的AngularJSSPA的详细情况,特别是关于vs怎么刷新的相关信息。我们将通过案例分析、数据研究等多种方式,帮助您更全面地了解这个主题,同时

本文将介绍如何正确刷新在VS 2015 Web开发环境中运行的AngularJS SPA的详细情况,特别是关于vs怎么刷新的相关信息。我们将通过案例分析、数据研究等多种方式,帮助您更全面地了解这个主题,同时也将涉及一些关于11 个对Web开发者非常有用的AngularJS工具、angularjs – Angular 2(4),Webpack站点将无法在IE 11中的服务器上运行、angularjs – WebSharper vs. Angular、angularjs – 使用Angular 2和VS2015 Update 2 – 获取npm -not安装错误的知识。

本文目录一览:

如何正确刷新在VS 2015 Web开发环境中运行的AngularJS SPA(vs怎么刷新)

如何正确刷新在VS 2015 Web开发环境中运行的AngularJS SPA(vs怎么刷新)

我有一个AngularJS SPA应用程序,我使用Visual Studio 2015开发.当我点击发布它发布index.html并且工作得很好.但是,如果我在页面上并单击刷新,则会尝试刷新SPA页面,例如example.com/home/about.这失败了,因为我没有家/关于页面.

有没有办法可以修改我的web.config文件(仅用于本地测试),以便它实际上转到index.html(加载它)然后转到/ home / about状态?

这是我当前的web.config:

<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
  </system.web>
</configuration>

解决方法

您似乎正在使用 html5mode.在这种情况下,没有#来保持URL从请求更改为服务器.
使用此配置,您需要来自服务器的帮助.当它收到来自SPA路线的请求时,它将为index.html提供服务.

这个SO answer有关于在web.config上配置URL Rewrite的详细信息:

规则通过:

<system.webServer>
    <rewrite>
      <rules>
        <rule name="AngularJS Routes" stopProcessing="true">
          <match url=".*" />
          <conditions logicalGrouping="MatchAll">
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
            <add input="{REQUEST_URI}" pattern="^/(api)" negate="true" />
          </conditions>
          <action type="Rewrite" url="/" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>

它假定您的API位于:/ api下,并且对于它找到的任何目录或文件,它按原样使用.
任何其他的,被重写为/将默认文档配置为index.html,将加载SPA.

另请注意,您需要安装URL Rewrite module for IIS(IIS Express doesn’t need the module)

另一个选项是这些轻量级HTTP服务器npm包之一.
John Papa has one: lite-server.它在引擎盖下使用BrowserSync:

browserSync does most of what we want in a super fast lightweight
development server. It serves the static content,detects changes,
refreshes the browser,and offers many customizations.

When creating a SPA there are routes that are only kNown to the
browser. For example,/customer/21 may be a client side route for an
Angular app. If this route is entered manually or linked to directly
as the entry point of the Angular app (aka a deep link) the static
server will receive the request,because Angular is not loaded yet.
The server will not find a match for the route and thus return a 404.
The desired behavior in this case is to return the index.html (or
whatever starting page of the app we have defined). browserSync does
not automatically allow for a fallback page. But it does allow for
custom middleware. This is where lite-server steps in.

lite-server is a simple customized wrapper around browserSync to make it easy to serve SPAs.

11 个对Web开发者非常有用的AngularJS工具

11 个对Web开发者非常有用的AngularJS工具

11 个对Web开发者非常有用的AngularJS工具

AngularJS 工具对你开发 AngularJS App 项目非常有帮助,下面的这些工具尤其适合用于创建单页面 WEB 应用。今天分享 11 个对WEB开发者非常有帮助的 AngularJS 工具,如果你还有其他很棒的工具,请在评论中留言让我们知道。

相关教程推荐:《angularjs教程》

1、AngularFire

AngularFire 提供了一种非常容易的创建 AngularJS 应用后台的方式,提供了灵活的API,3种方式的数据绑定,以及快速的开发能力。

地址:https://www.firebase.com/docs/web/libraries/angular/index.html

2、Protractor

Protractor 是一个 AngularJS 应用程序终端到终端的测试框架。Protractor 可以在真实的浏览器中运行测试你的程序。

地址:http://angular.github.io/protractor/#/

3、Aptana

使用业界领先的WEB应用程序 IDE 来快速简便的构建 WEB 应用。Aptana Studio 利用了 Eclipse 的灵活性,并把它集成到一个功能强大的Web开发引擎。

地址:http://www.aptana.com/

4、Lumx

第一款基于 AngularJS 和 Google Material Design 的响应式前段框架。

地址:http://ui.lumapps.com/

5、Mobile Angular UI

Mobile Angular UI 是一个使用BootStrap 3 和 AngularJS 创建 HTML5 应用的前段框架。

地址:http://mobileangularui.com/

6、UI Bootstrap

由 AngularUI 团队开发的,纯 AngularJS 编写的 BootStrap 组件。这个库包含了一套基于 BootStrap 标记和CSS的AngularJS指令。

地址:http://angular-ui.github.io/bootstrap/

7、Yeoman

Yeoman 帮你快速启动新的项目、提供最佳的实践以及使你保持高效的工具。

地址:http://yeoman.io/

8、Videogular

Videogular 是一个由AngularJS 开发的支持PC端和移动端的视频应用框架。Videogular 使用 HTML5 的 video 标签,所以你可以添加任何你想要的。

地址:http://www.videogular.com/

9、Appery.io

Appery 是一个基于云平台的,使用私有/公共云方案开发移动端响应式应用的框架。

地址:https://appery.io/

10、Colt.io

COLT 是一个小的程序,可以实时的测试、创建移动端、WEB端和基于桌面的应用程序。

地址:http://codeorchestra.com/#/

11、Angular Gettext

Angular gettext 是一个 AngularJS 超级简单的翻译支持。所有的都用英语编写,并且标记出哪部分需要翻译。

地址:https://angular-gettext.rocketeer.be/

更多编程相关知识,可访问:编程教学!!

以上就是11 个对Web开发者非常有用的AngularJS工具的详细内容,更多请关注php中文网其它相关文章!

angularjs – Angular 2(4),Webpack站点将无法在IE 11中的服务器上运行

angularjs – Angular 2(4),Webpack站点将无法在IE 11中的服务器上运行

在角度或webpack中是否有一些特殊的IE开关,因为当我在 http://localhost:port/上运行我的网站时,它可以工作.此外,当我在Edge或Chrome上的服务器 http://server.domain/mysite/上运行它时,它可以工作.但是当我在IE 11上打开它(兼容模式设置为11)时,我在控制台中收到以下错误:

未处理的Promise拒绝:无法加载函数t(t){var e = this; this.http = t,this.getItems = function(){e.results = null,e.http.get(“api / app / components /my-items.component.html; Zone :;任务:Promise.then;值:无法加载函数t(t){var e = this; this.http = t,this.getItems = function(){e. results = null,e.http.get(“api / app / components / my-items.component.html undefined

对我来说意味着什么的唯一部分是’api /’是完全错误的,并且我已经仔细检查了组件,它清楚地说:

@Component({
    selector: 'my-items',templateUrl: 'app/components/my-items.component.html'
})
export class MyItemsComponent implements OnInit { ...

整个解决方案中没有出现短语’api / app'(包括c#,ts,css,html和js文件)

我的webpack.config.js很简单:

/// <binding ProjectOpened='Watch - Development' />
var path = require('path');
var webpack = require('webpack');
var console = require('console');


module.exports = {
    context: path.join(__dirname,'wwwroot'),//vendor: ['libs/@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js'],entry: './app/main.js',output: {
        path: path.join(__dirname,'wwwroot/built'),filename: '[name].bundle.js',},plugins: [
            //new webpack.optimize.CommonsChunkPlugin("vendor","vendor.bundle.js"),// split vendor js into its own file
    new webpack.optimize.CommonsChunkPlugin({
      name: 'vendor',minChunks: function (module,count) {
          // any required modules inside node_modules are extracted to vendor
          var path = module.resource.replace(/\\/g,'/');

          return (/\.js$/.test(path) && (path.indexOf('node_modules/') >= 0 || path.indexOf('libs/') >= 0));
      }

};

这里发生了什么?

解决方法

我使用2.0.0-rc.1和webpack遇到了同样的问题.在阅读了一些 issues之后,我的解决方案是在浏览器是IE时在我的index.html上包含以下脚本:

es6-shim.min.js
system-polyfills.js
shims_for_IE.js

前两个可以在node_modules中找到,我从here下载了第三个.

angularjs – WebSharper vs. Angular

angularjs – WebSharper vs. Angular

Angular可以使用ui-router来定义状态,以便在应用程序中移动.例如.当仍然在一个页面上时,您可以在页面的左侧有列表视图,同时在右侧有详细视图.然后,每当您从左侧列表更改记录时,详细信息也会更改,但是,您仍然在同一页面中.
是否有可能在WebSharper中,或者还有其他选项如何处理场景?

此外,angular具有模板(和指令)的概念.除其他外,这使得能够将本机HTML代码包装到模板中,并将其用作其他一些html页面中的指令的一部分.例如,可以使用像select2这样的javascript库.这也可能在WebSharper中,例如使用select2库?

解决方法

我对Angular不是很熟悉,但您列出的大多数功能都可以在WebSharper中作为扩展名使用: WebSharper.UI.Next.您可以像定义的那样定义客户端路由.它也有模板,但它仍在进行中,所以还没有文档(但我们已经在我们的项目中积极使用它).整个库旨在用于创建反应式单页应用程序,因此它可以作为角度的替代品(当然不是那么广泛).

至于模板:由于您是用F#编写代码,因此在UI.Next中有一个方便的DSL用于处理HTML组合器,因此您可以在F#中定义视图并在整个项目中重复使用它们,直到我们使模板更易于使用.

您可以使用外部库(如select2),但它需要一些额外的工作,即定义库的类型(或至少您要使用的部分类型).由于您正在编写F#代码,因此您需要知道事物的显式类型,因此您必须为处理类型的JavaScript库编写“绑定”.一方面它很棒,因为你现在有类型,另一方面它对于大型项目来说会变得相当繁琐.有关如何执行此操作的详细信息,请查看WIG documentation.

angularjs – 使用Angular 2和VS2015 Update 2 – 获取npm -not安装错误

angularjs – 使用Angular 2和VS2015 Update 2 – 获取npm -not安装错误

我创建了一个空核1.0 Web应用程序,并添加了一个package.json文件,复制angular2快速启动package.json行 from this url.

我一直收到消息Dependencies – 未安装和npm – 未安装.

有谁知道为什么会这样?我是否必须在我的PC上实际安装node.js才能使Visual Studio能够使用它?鲍尔工作完美……

此问题正在跟踪此问题:
https://github.com/aspnet/Tooling/issues/479

将Visual Studio重新定位到不同的npm路径可能不会产生任何影响 – Visual Studio似乎仍然将对Windows不支持的程序包的依赖性解释为一个突破性问题.

这只是一个IDE问题.您仍然可以在不解决此问题的情况下构建和运行.

但是,如果您希望删除未安装的指示符,请识别并删除违规包,然后手动删除node_modules文件夹,并重新保存package.json.

我们今天的关于如何正确刷新在VS 2015 Web开发环境中运行的AngularJS SPAvs怎么刷新的分享已经告一段落,感谢您的关注,如果您想了解更多关于11 个对Web开发者非常有用的AngularJS工具、angularjs – Angular 2(4),Webpack站点将无法在IE 11中的服务器上运行、angularjs – WebSharper vs. Angular、angularjs – 使用Angular 2和VS2015 Update 2 – 获取npm -not安装错误的相关信息,请在本站查询。

本文标签: