In this plunker: http://plnkr.co/edit/OZa7rvWLQuRHJGiJ8dBL?p=preview
I'm having difficulty adding $http.get
to the controller so that the page runs.
In app.js --
I have this code:
angular.module('example-app', ['hc.marked', 'hljs'])
.config(['markedProvider', 'hljsServiceProvider', function(markedProvider, hljsServiceProvider) {
// marked config
markedProvider.setOptions({
gfm: true,
tables: true,
sanitize: true,
highlight: function (code, lang) {
if (lang) {
return hljs.highlight(lang, code, true).value;
} else {
return hljs.highlightAuto(code).value;
}
}
});
}])
.controller("MainController", ["$rootScope", "$scope", "marked", function MarkdownController($rootScope, $scope, marked, $http) {
}]);
How to add this $http.get
so that the plunker continues to work properly??
$http.get('http://beta.json-generator.com/api/json/get/VyD_JWT1Q')
.then(function (res) {
$scope.todos = res.data.todo;
$scope.events = res.data.event;
$scope.aboutlongs = res.data.aboutlong;
$scope.mainpoints = res.data.mainpoint;
$scope.tags = res.data.tag;
$scope.galleries = res.data.gallery;
$scope.menus = res.data;
$scope.socials = res.data.social;
});
I've tried this, but it breaks:
angular.module('example-app', ['hc.marked', 'hljs'])
.config(['markedProvider', 'hljsServiceProvider', function(markedProvider, hljsServiceProvider) {
// marked config
markedProvider.setOptions({
gfm: true,
tables: true,
sanitize: true,
highlight: function (code, lang) {
if (lang) {
return hljs.highlight(lang, code, true).value;
} else {
return hljs.highlightAuto(code).value;
}
}
});
}])
.controller("MainController", ["$rootScope", "$scope", "marked", function MarkdownController($rootScope, $scope, marked, $http) {
$http.get('http://beta.json-generator.com/api/json/get/VyD_JWT1Q')
.then(function (res) {
$scope.todos = res.data.todo;
$scope.events = res.data.event;
$scope.aboutlongs = res.data.aboutlong;
$scope.mainpoints = res.data.mainpoint;
$scope.tags = res.data.tag;
$scope.galleries = res.data.gallery;
$scope.menus = res.data;
$scope.socials = res.data.social;
});
}]);
Thanks in advance.