发表于: 2017-04-20 21:47:14

1 1171


今天完成的事情:

ui路由的配置,可以在用一个视图内进行三个页面的切换。


明天的计划:

进行双向绑定,ng-model的实践和其他指令的学习。


遇到的问题:

1 controller里获取不到ng-model的值,获取为undefine。

html:ng-model=“test”,但是在controller里打印的$scope属性里面并未发现test,控制台打印test为undefined,页面上{{test}}却可以正常输出来。

scope不一样解决方法:在html里添加$parent


2 路由设置对象的几个参数的理解:

template:

如果我们只需要在 ng-view 中插入简单的 HTML 内容,则使用该参数;

templateUrl:如果我们只需要在 ng-view 中插入 HTML 模板文件,则使用该参数;

$routeProvider.when('/computers', {

    templateUrl: 'views/computers.html',

});

以上代码会从服务端获取 views/computers.html 文件内容插入到 ng-view 中。

controller:function、string或数组类型,在当前模板上执行的controller函数,生成新的scope。

controllerAs:string类型,为controller指定别名。

redirectTo:重定向的地址。

resolve:指定当前controller所依赖的其他模块。


收获:

以上



返回列表 返回列表
评论

    分享到