Giter Club home page Giter Club logo

angularstudy's Introduction

Angular 前端学习项目

v1.1 程序:

http.zip的demo为基础,添加了route导航的内容,完成各个页面的切换。

界面1

v1.2 程序:

加入了HttpService服务,用来获取服务端的数据并进行显示,http://1.15.109.169:9950/posts 为请求的接口,下面的json为返回的结果。

临时注释了,index.ts里面httpInterceptorProviders,拦截器的代码,因为拦截器需要强制https访问等。且服务端也做了修改,以解决异域访问的问题。

//解决has been blocked by CORS policy: No 'Access-Control-Allow-Origin' 
//header is present on the requested resource.
header += "Access-Control-Allow-Origin: *\r\n";

界面2

v1.3 程序:

引入惰性加载特性模块。Admin Component,后续考虑引入导航树结构,便于界面的扩展。

默认情况下,NgModule 都是急性加载的,也就是说它会在应用加载时尽快加载,所有模块都是如此,无论是否立即要用。对于带有很多路由的大型应用,考虑使用惰性加载 —— 一种按需加载 NgModule 的模式。惰性加载可以减小初始包的尺寸,从而减少加载时间。

界面3

v1.4 程序:

针对HttpService服务,加入了对服务器端数据的访问接口,通过输入api/database/student,调用http服务,转向用get方法获取http://1.15.109.169:9950/database/student 的数据。

界面4

其中,代理文件proxy.config.json如下:

将/api的调用转向http://1.15.109.169:9950

{
  "/api2": {
     "target": "http://1.15.109.169:9950/api2"
  },
  "/api": {
    "target": "http://1.15.109.169:9950",
    "secure": false,
    "changeOrigin": true,
    "pathRewrite": {"^/api":""}
 }
}

angularstudy's People

Contributors

klc407073648 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.