Does not work angular ngview js

0

Good morning this is my index.html

<!DOCTYPE html>
<html ng-app="crudBasicApp">
<head>
<title>CRUD Angular!</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="Content/bootstrap.css" />
</head>
<body ng-controller="IndexController">
<h1 class="text-center">{{TitleApp}}</h1>

<div>
    <button ng-click="Click()" class="btn btn-danger">Dar clic please</button>
</div>

<a href="#about">About</a>
<a href="#home">Home</a>

<div ng-view></div>

<script type="text/javascript" src="Scripts/angular.min.js"></script>
<script type="text/javascript" src="js/Config.js"></script>
<script type="text/javascript" src="Scripts/angular-route.min.js"></script>
<script type="text/javascript" src="js/app/IndexController.js"></script>

this is my config.js

var CRUDBasico = angular.module('crudBasicApp', ['ngRoute']);
//var CRUDBasico = angular.module('crudBasicApp', []);

CRUDBasico.config(function ($routeProvider) {
$routeProvider

    .when('/', {
        templateUrl: 'Views/About.html'
    })
    // route for the home page
    //.when('/home', {
    //    templateUrl: 'Home.htm'
    //})

    // route for the about page
    .when("/home", {
        templateUrl: 'Views/Home.html'
    });
});

and this my indexController

CRUDBasico.controller('IndexController', function ($rootScope, $scope, $http) {

$rootScope.TitleApp = 'Angular Basic CRUD';
$rootScope.pageIncludeTitle = 'Esta página esta incluida';

$scope.Click = function () {
   };
});

The strange thing is that it wants to work with single page but when I click to change the page it stays in this URL http://localhost:52252/#!/#home , it does not change and the console does not get any error.

    
asked by Julian Vasquez Perez 26.03.2017 в 21:35
source

2 answers

0

I think this error with the routes can be resolved by activating the html5 mode. Basically it is done like this: $locationProvider.html5Mode(true); Here you have documentation: link $ locationProvider

    
answered by 27.03.2017 в 09:28
0

You should have a configuration like this:

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

        .state('app', {
        url: '/app',
        abstract: true,
        templateUrl: 'templates/menu.html',
        controller: 'AppCtrl'
    })
    
answered by 27.03.2017 в 11:49