angularjs 代码结构两种写法

时间:2023-03-08 22:12:34
angularjs 代码结构两种写法

1、当路由中不写controller的时候,controller写在对应的html表单中

angularjs 代码结构两种写法angularjs 代码结构两种写法

2、若要写在路由中,如下

angularjs 代码结构两种写法

3、转到相应的路由(页面)

1、采用location服务

angularjs 代码结构两种写法

2、采用 transitionTo

angularjs 代码结构两种写法

 4、含有导航标题的可以采用abstract:true,默认会先加载父页面

angularjs 代码结构两种写法

angularjs 代码结构两种写法

 5、angularjs 代码的两种写法

1、模块化写法 将config,service,controller js写在一个js文件中,,每个模块只有一个js,以及所有的html页面

angularjs 代码结构两种写法

angularjs 代码结构两种写法

2、第二种写法 按照功能划分。比如有三个模块,那么三个模块的的config写在一个文件中config.js,三个模块的的service写在一个文件service.js中,三个模块的的controller写在一个文件controller.js中,

angularjs 代码结构两种写法