I'm trying to get angular working in my dotnet webapi project. I've installed angular and angular-ui-router through npm and all scripts added to my default.html page with development and stage/production.
To test it, i've written the following:
<body ng-app="myApp">
<h1>hello</h1>
{{2+2}}
</body>
This code doesn't work and gives me the error: Error: $injector:modulerr Module Error. It can't get myApp. I've included the app.js in default.html where myApp is.
angular.module('myApp', [
I have tried with ui-view and added a .state, but that doesn't work either. the {{2+2}} works though, if i only type ng-app in tag. What am i doing wrong?
Thanks in advance.
your dependency is wrong. You should use
angular.module('myApp', ['ngRoute']);
See Fiddle
ui.route
stands for AngularUI router , but angular-route
(the one you added in the fiddle) stands for ngRoute
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.