angularjs - ng-view的“Controller as”语法

标签 angularjs ngroute

我想知道如何将Controller as语法与ngRoute结合使用,因为我无法执行ng-controller="Controller as ctrl"

最佳答案

controller as配置中指定 Controller 时,可以使用$routeProvider语法。

例如

$routeProvider
    .when('/somePath', {
        template: htmlTemplate,
        controller: 'myController as ctrl'
    });

关于angularjs - ng-view的“Controller as”语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23861101/

相关文章:

javascript - 带 MD 菜单的 MD 日期选择器

javascript - AngularJS 单元测试中的模拟模块依赖关系

javascript - Angular.js - 在范围内使用函数的优雅方式

javascript - 在 ngRoute 中使用嵌套 Controller - AngularJS

javascript - AngularJS 路由从 json 数据创建所有相同的 View 模板

angularjs 1.6.0(现在最新)路线不起作用

javascript - AngularJS 嵌套范围/ View

angularjs - Nodejs 和 Express : How to send multiple Json variable from server to Client through response. 发送()

javascript - AngularJS - $routeProvider 和 data-ng-view 的问题

angularjs - Angular ngRoute 无法获取 View