R
R
RodgerFox2015-06-14 08:08:09
Angular
RodgerFox, 2015-06-14 08:08:09

How to do something in Angular?

<div id="content" ng-app="GridSystem">
  <div ng-view></div>
</div>
<script type="text/javascript">
  app.run(
        function($rootScope) {
            $rootScope.actionMain = '<?php echo $action ?>';
            $rootScope.token = "<?php echo $token ?>";
            $rootScope.toId = "<?php echo $module_id ?>";
            $rootScope.storeUrl = "<?php echo $store_url ?>";
           });
</script>

angular.module('GridSystem', ['ngRoute','ngResource'])
    .config(function($routeProvider, $rootScope){
        $routeProvider.when($rootScope.storeUrl+'/',
        {
            templateUrl: "flex/IceStart.html",
            controller: 'IceStart'
        });
        $routeProvider.when('/creat',
        {
            templateUrl:'flex/CreatGrid.html',
            controller:'CreatGridController'
        });
        $routeProvider.when($rootScope.storeUrl+'/:'+$rootScope.token+':toid',
        {
            controller: 'EditController'
        })
        $routeProvider.otherwise({
            template: "This route isn't set!"
        });
    });

function MainCtrl($scope) {
....
}

https://code.angularjs.org/1.4.0/angular.min.js
https://code.angularjs.org/1.4.0/angular-route.min.js
https://code.angularjs.org/1.4.0/angular-resource.min.js

Falls out: Uncaught Error: [$injector:modulerr] ( link )
Well, I've tried everything, I can't do anything beyond the documentation. Am I the only one so dumb?
UPD.
Added $rootScope, set it in the main file, use $rootScope.storeUrl to specify an adequate url in the route config, approx. $routeProvider.when($rootScope.storeUrl+'/', although before that I put it in the $rootScope function, I don't understand this rigidity of angular...

Answer the question

In order to leave comments, you need to log in

3 answer(s)
_
_ _, 2015-06-14
@AMar4enko

You have two links, they have different errors.
So what is the error anyway?
UPD: codepen.io/AMar4enko/pen/rVzaYY
There are comments there. I think they will be enough.

S
Singularity, 2015-06-14
@Singularity

ngRoute is not optionally supplied, it must be additionally included in html.
As it says in the link, by the way:

Using ngRoute
In AngularJS 1.2.0 and later, ngRoute has been moved to its own module. If you are getting this error after upgrading to 1.2.x or later, be sure that you've installed ngRoute.

L
lega, 2015-06-14
@lega

Try Angular Light

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question