gpt4 book ai didi

javascript - 单击链接两次以激活 ui router 的状态

转载 作者:行者123 更新时间:2023-11-28 06:39:18 26 4
gpt4 key购买 nike

最初,学年状态处于事件状态。

当我单击按钮激活 schoolyears.create 状态时,我必须执行此操作两次。只有这样,才会呈现创建学年 View 。

我做错了什么?

INDEX.HTML

// navbar removed for brevity

<div ui-view="content" class="container body-content">
CONTENT
</div>

app.js

'use strict';
angular
.module('TGB', ['ui.router', 'ui.bootstrap'])

.run(['$rootScope', '$state', '$stateParams',
function ($rootScope, $state, $stateParams) {

$rootScope.$state = $state;
$rootScope.$stateParams = $stateParams;

}
])
.config(function ($stateProvider, $urlRouterProvider) {

//localStorageServiceProvider.setPrefix('TGB');
$urlRouterProvider.otherwise("schoolyears");
$stateProvider
.state('schoolyears', {
url: '/schoolyears',
views: {
'content@': {
templateUrl: "/js/schoolyears/schoolyears.html",
controller: 'SchoolyearsController'
}
}
})
.state('schoolyears.selected', {
url: '/:id'
})
.state('schoolyears.create', {
url: '/create',
views: {
'content@': {
templateUrl: '/js/schoolyears/createSchoolyear.html',
controller: 'CreateSchoolyearController'
}
}
})
});

SchoolyearsController.js

(function () {
'use strict';

angular
.module('TGB')
.controller('SchoolyearsController', SchoolyearsController);

function SchoolyearsController($scope, $state) {

$scope.schoolyears = [];
}
})();

CreateSchoolyearController.js

(function () {
'use strict';

angular
.module('TGB')
.controller('CreateSchoolyearController', CreateSchoolyearController);

function CreateSchoolyearController($scope, $state) {



}
})();

最佳答案

我想说,只需设置如下状态

    .state('schoolyears.create', {
url: '/create',
views: {
'content@schoolyears': {
templateUrl: '/js/schoolyears/createSchoolyear.html',
controller: 'CreateSchoolyearController'
}
}
})

关于javascript - 单击链接两次以激活 ui router 的状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33988627/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com