gpt4 book ai didi

javascript - 如何在$location.path之后的其他页面上使用 Angular js中的 View ?

转载 作者:行者123 更新时间:2023-11-28 05:14:39 24 4
gpt4 key购买 nike

这是我的 app.js

var mainApp = angular.module("myapp", ['ngRoute']);
mainApp.config(['$routeProvider', function($routeProvider) {
$routeProvider.

when('/', {
templateUrl: '/search/login.html'
}).

when('/dashboard', {
templateUrl: 'admin/index.html'
}).

otherwise({
redirectTo: '/'
});

}]);

mainApp.controller('logincntrl',function($scope,$location){
$scope.submit=function(){
var uname=$scope.username;
var upass=$scope.password;
if($scope.username=="admin" && $scope.password=="admin"){
$location.path('/dashboard');
}
};
});`

点击提交后。它将重定向到仪表板..这是带有索引的单独文件夹。但是正如我在第一页上给出的 View ..我的仪表板即使有样式也包含在第一页上..如何制作仪表板页面的单独 View

最佳答案

You can use <ng-view><ng-view> to have load different partials. You can have a look into this to have an idea http://codepen.io/dhanrajjay/pen/dOjmxL/

关于javascript - 如何在$location.path之后的其他页面上使用 Angular js中的 View ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41074919/

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