问题描述:

Hi,

I just start to use AngularJS to make applications and I just found a weird problem. I search for similar issues nevertheless I didn't find anything to solve it - that's why i'm here folks ! :) -.

My project specifications : AngularJS, NodeJS, Yeoman, Grunt, Bower

The "main" of my website is index.html. It contains the header, the footer and this is it where I include all the common stuff (navbar, etc...) and the ng-view.

I'm working on localhost:3502.

Like I said in the title, all the directives are not working in my ng-view.

However, anything is fine in the index.html page.

I had activated the debug mode but there was no error !

I will show you an exemple.

index.html

<html ng-app="3DevApp">

<head>

// ...

</head>

<body>

<!-- I work very good, sir -->

<div ng-controller="ViewCtrl">

<button ng-click="changeView('HelloWorld')">Say hi</button>

</div>

<div ng-view></div>

</body>

</html>

main.js

angular.module('3DevApp')

.controller('ViewCtrl', function($scope, $location) {

$scope.changeView = function(view) {

$location.path(view);

}

});

So, this is working great. The ng-view changed (the default loaded view is main.html).

And now, if I copy and past the code in the my main view main.html the directive will not work.

Any of them in fact.

main.html

<!-- I dunno want to work :) -->

<div ng-controller="ViewCtrl">

<button ng-click="changeView('HelloWorld')">Say hi</button>

</div>

Thanks for the help.

网友答案:

Two words : Holly shit.
I found the solution by my own after hours of search...
My others controllers weren't automatically include by bower.
I included them manually and now it works even if these controllers have nothing in common with this controller...
Sorry.

相关阅读:
Top