So I have a custom directive that makes an http get requests and displays on a another template. But it doesn't display anything
The documentdisplay.js file where i have created the directive
/**
* @author Karan Shah
*
*/
var documentDisplayModule = angular.module('ald.documentdisplay',[]);
documentDisplayModule.factory('documentDisplayAPI',function(){
var fac ={};
fac.getContents = function($http,docName){
return $htp({
method: 'GET',
url: "/document/getContents/docName?="+docName
});
};
return fac;
});
documentDisplayModule.directive('doccontent', function () {
return {
restrict: 'EA',
scope: {},
replace: true,
link: function ($scope, element, attributes) {
},
controller: function ($scope, $http,$routeParams, documentDisplayAPI) {
documentDisplayAPI.getContents($http,$routeParams.doc).success(function(data,status){
$scope.textofdocument = data;
}).error(function(data,status){
if (404==status){
alert("no text");
} else {
alert("bad stuff!");
}
});
},
templateUrl: "documentcontent.html"
};
});
The html page where I am calling it
<!-- @author Karan Shah -->
<body>
<div>
<h1>Document Display Contents</h1>
<doccontent/>
</div>
</body>
and the templateUrl the documentcontent.html which has the display
<body>
<div>
Hello World
<div>
<a href="#/documents">Back to the List of Documents</a>
</div>
<br>
{{textofdocument}}
</div>
</body>
error that I am getting :
Error: [jqLite:nosel] Looking up elements via selectors is not supported by jqLite! See: http://docs.angularjs.org/api/angular.element
http://errors.angularjs.org/1.2.21/jqLite/nosel
at https://ajax.googleapis.com/ajax/libs/angularjs/1.2.21/angular.js:78:12
at JQLite (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.21/angular.js:2365:13)
at https://ajax.googleapis.com/ajax/libs/angularjs/1.2.21/angular.js:6816:27
at https://ajax.googleapis.com/ajax/libs/angularjs/1.2.21/angular.js:8074:11
at deferred.promise.then.wrappedCallback (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.21/angular.js:11520:81)
at deferred.promise.then.wrappedCallback (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.21/angular.js:11520:81)
at https://ajax.googleapis.com/ajax/libs/angularjs/1.2.21/angular.js:11606:26
at Scope.$RootScopeProvider.$get.Scope.$eval (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.21/angular.js:12632:28)
at Scope.$RootScopeProvider.$get.Scope.$digest (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.21/angular.js:12444:31)
at Scope.$RootScopeProvider.$get.Scope.$apply (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.21/angular.js:12736:24)
The content is not displayed. I am not sure what is wrong here. Thanks