Hi Benjamin, 

I plnkr is always recommended to illustrate your problem.  Questions with 
embedded code are not recommended and often ignored.
A good starting point is this template created by Sander: 
http://plnkr.co/edit/xLdPUYN36w1gjiBmZWTX?p=info

I'm feeling generous today, so here is a plnkr 
<http://plnkr.co/edit/cPMf0l?p=preview>with code, slightly modified so that 
it works.

Two things:
1) Use the developer console of your browser to look for errors

2) The following is not valid JSON
{name:"view"}

Yes, its a valid JavaScript Object Literal 
<https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Values,_variables,_and_literals#Object_literals>
 
and the two are often confused.  JSON is a interchange format (with its own 
set of rules).  This is valid JSON:

{"name":"view"}

Also:

   - 
   
http://stackoverflow.com/questions/2904131/what-is-the-difference-between-json-and-object-literal-notation
   - http://stackoverflow.com/questions/8294088/javascript-object-vs-json

Regards
Justin


On Monday, October 27, 2014 4:32:20 PM UTC+2, benjamin wrote:
>
> Hi all,
> I'm new to angularjs and I can't see why my code is blocked.
> I have an html page like this:
>
> <body ng-app="table"> <view-products></view-products> </body>
>
> I want a directive named viewProducts to be inserted there
> my app.js:
> var route = '/learn/angularjs/';
> var app = angular.module("table",[]);
>
> app.directive("viewProducts",function(){
>  return{
>  restrict:"E",
>  templateUrl:route+"includes/view.html",
>  controller:['$scope','$http',function($scope,$http){
>  $http.get(route+'includes/view.json').success(function(data){
>  $scope.view = data;
>  });
>  }],
>  controllerAs:"view"
>  };
> });
>
>
> view.html:
>
> <div> {{view.name}} </div>
>
> view.json
>
> {name:"view"}
>
> When I open the browser I have a white page,
> don't understand why.
>
> Thank you for your help
> Benjamin
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to