ng-click does not work with ng-view

0

I have started to create a page. it has header and main, the main loads the views and it works perfectly, but I want that when the secondary views are loaded the header is hidden, here the index:

<html>
<head>
    <link rel="stylesheet" href="css/estilo.css">
    <link rel="stylesheet" href="css/sistemas.css">
    <link rel="stylesheet" href="css/desarrollo.css">
    <link rel="stylesheet" href="css/personal.css">
    <link rel="stylesheet" href="css/profesional.css">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
    <script src="js/angular.js"></script>
    <script src="bower/angular-route.min.js"></script>
    <script src="bower/angular-route.js"></script>
    <script src="bower/angular-route.min.js"></script>
    <script src="js/main.js"></script>
    <script src="js/sistemas.js"></script>
    <script src="animate/angular-animate.js"></script>
</head>
<body ng-app="app" >
    <main ng-controller="mainController" ng-init="ver=true">
        <section class="cabecera" ng-show="ver==true">
            <article>
                <!-- Aquí va la cabecera -->
            </article>
        </section>
        <section class="cuerpo" ng-view ng-click="ver=showTitle();">

        </section>
    </main>
</body>

and here the js:

var app = angular.module('app', [ 'ngRoute', 'ngAnimate']);
app.config(function($routeProvider, $locationProvider){
$locationProvider.hashPrefix('');
$routeProvider
    .when('/', {
        templateUrl: 'views/main.html'
    })
    .when('/sistemas', {
        templateUrl: 'views/sistemas.html'
    })
    .when('/desarrollo', {
        templateUrl: 'views/desarrollo.html'
    })
    .when('/profesional', {
        templateUrl: 'views/profesional.html'
    })
    .when('/personal', {
        templateUrl: 'views/personal.html'
    })
    .otherwise({
        redirectTo: '/'
    });
});

app.controller('mainController', function($scope){
$scope.showTitle = function() {
var ver = $scope.ver;
    if (ver == true) {
        ver=false;
    } 
    else {
        ver=true;
    }
return ver;
}
});

If I put it in any other section it works perfectly, but it seems that the ng-view interferes with the operation of the ng-click, has anyone else happened to it?

* edited: sorry for putting it in English at the beginning, almost all posts I've seen of angular were in English.

    
asked by Jorge c 25.08.2017 в 03:46
source

1 answer

0

Solved, a friend helped me with this, it's a scope problem, you have to declare the variable in $ rootscope, from app.run

    
answered by 05.09.2017 в 11:48