0

I will show you the code on jsbin. the issue is : $scope.name never show,thank you

http://jsbin.com/buwij/1/edit

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.14/angular.min.js"></script>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body ng-app="test">
  <a href="#/you">go to</a>
  <ng-view></ng-view>
  <script type="text/ng-template" id="you.html">
    {{name}}
  </script>
</body>
</html>

js:

var test = angular.module('test',[]);
test.config(function($rootProvider){
  $rootProvider
    .when('/you',{
      templateUrl: 'you.html',
      controller: 'youCtrl'
    });
});

test.controller('youCtrl',function($scope){
  $scope.name = 'you';
});
1
  • 2
    its $routeProvider not $rootProvider and you need to add the ngRoute dependency Commented Mar 27, 2014 at 13:41

1 Answer 1

1

Heres a quick plnkr

You were missing the ngRoute dependency and script on your module

<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.14/angular-route.js"></script>

and you need to setup your module like so var test = angular.module('test',['nRoute']);

and its $routeProvider not $rootProvider simple spelling error.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.