I
I
IvanN7772016-01-16 15:00:42
Angular
IvanN777, 2016-01-16 15:00:42

I'm learning Angular, I follow the link to the page and the Angular markup is visible, if I then press F5 everything is fine.?

Angular Code

var BookShop = angular.module('BookShop', ['ngResource']);

BookShop.factory("BookFactory", function($resource) {
    return $resource("books/:id", { id: '@id' }, {
        index:   { method: 'GET', responseType: 'json' },
        update:  { method: 'PUT', responseType: 'json' }
    });
})

BookShop.controller("BookCtrl", function($scope, BookFactory) {
    $scope.books = BookFactory.index()

    $scope.addBook = function() {
        book = BookFactory.save($scope.newBook)

        $scope.books.push(book)
        $scope.newBook = {}
    }

    $scope.deleteBook = function(index) {

        book = $scope.books[index]
        BookFactory.delete(book)
        $scope.books.splice(index, 1);
    }
})

Angular slim markup
.container
  h1 Библиотека
  div ng-controller="BookCtrl"
    .well
      h3 Добавить новую книгу
      form ng-submit="addBook()"
        .row
          .col-xs-6
            input.form-control ng-model="newBook.name" placeholder=("Название книги") type="text" /
          .col-xs-6
            input.form-control ng-model="newBook.description" placeholder="Описание" type="text" /
        .row
          .col-xs-12
            br/
            input.form-control ng-model="newBook.cover_image" type="text" /
        .row
          .col-xs-12
            br/
            input.form-control ng-model="newBook.create_at" type="text" /
        .row
          .col-xs-12.text-center
            br/
            input.btn.btn-primary type="Submit" value=("Добавить книгу") /
    h3 Доступные книги
    hr/
    table.table.table-bordered.table-striped
      thead
        tr
          th Имя
          th Краткое описание
          th Дата создания
          th Действия
      tbody
        tr ng-show="!books.length"
          td colspan="4"  В библиотеке нет книг
        tr ng-repeat=("book in books | orderBy:'-create_at'")
          td
            | {{ book.name }}
          td
            | {{ book.description }}
          td
            |{{ book.create_at }}
          td
            a.btn.btn-danger ng-click="deleteBook($index)"  Удалить

If I am on the page, then everything is fine.
But if I follow the link, then the Angular markup is visible, what could be the reason for this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Korolev, 2016-01-16
@IvanN777

TurboLinks not enabled by any chance?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question