Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var blogSite = angular.module("blogSite", ["ngRoute"]);
- blogSite.config(['$routeProvider', function ($routeProvider) {
- $routeProvider
- .when("post/:post", {
- teplateUrl: 'blogpost.html',
- controller: 'blogPostController'
- })
- .otherwise({
- redirectTo: 'index.html'
- });
- }]);
- blogSite.controller("mainPageController", function ($scope, $http, $routeParams) {
- var url = baseUrl + "getpost";
- $http.get(url)
- .success(function (data, status, headers, config) {
- if (data.length > 0) {
- $scope.LastBlogPosts = data;
- }
- else {
- $scope.LastBlogPosts = null;
- }
- })
- .error(function (data, status, headers, config) {
- console.log(status);
- });
- });
- blogSite.controller("blogPostController", function ($scope, $http, $routeParams) {
- $scope.TestMessage = "Test Message"
- });
- div ng-controller="mainPageController">
- <ul>
- <li ng-repeat="blogPost in LastBlogPosts">
- <a href="post/{{blogPost.PostUrl}}" class="lastPostUrl mainPagePostTitle">{{blogPost.PostTitle}}</a>
- </li>
- </ul>
- </div>
- </div>
- </div>
- <div ng-view>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement