A
A
artjerom2016-01-30 21:01:06
JavaScript
artjerom, 2016-01-30 21:01:06

Why doesn't ng-controller work in jade?

ng-controller and everything after it does not work. I tried writing in html and it worked.

<!DOCTYPE html>
html(lang="ru" ng-app="DemoCtrl")
head
  meta(charset="UTF-8")
  link(rel="stylesheet", href="css/style.css")
  script(src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.9/angular.min.js")
  script(src="js/all.js")
  title appEx
body

  .container
   {{ 2 + 8 }} //-работает
    h1 ExampleApp

    form.search#search
     p.text-search
       input.field-search(type="search" name="search" placeholder="Поиск по сайту")
       input.button-search(type="submit" value="Найти")

    hr

    .books(ng-controller="example")
      .book
        {{ 2+12 }} //-не работает
        h3.work {{name}} //-не работает

Here is the js file code:
var DemoCtrl = angular.module('DemoCtrl', []);

    DemoCtrl.controller('example', function ($scope) { 
        $scope.name = "lorem ipsum dolor"
    });

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Anton Konyushevsky, 2016-01-30
@artjerom

https://output.jsbin.com/besujeqeke - everything works, check indentation in jade or build in html.

A
Andrey Dyrkov, 2016-01-30
@VIKINGVyksa

Ну так попробуйте на другую строку перенести {{name}} ведь {{ 2 + 8 }} на одной строке а {{name}} на одной строке с h3.work

A
artjerom, 2016-01-30
@artjerom Автор вопроса

Нужно было убрать плагин gulp-uglify. Т.к. он заменяет $scope

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question