Search code examples
angularjsslim-lang

How to add ng-app into a slim template


I need to add my ng-app=myApp into my application.html.slim. Im having problems that I can not find blogs on how to do this and its not in the slim docs. I have to put my ng-app in this file. How do insert it?

doctype html
head
  title PlanoX
  = stylesheet_link_tag("application", media: "all")
  = javascript_include_tag("application")
  = csrf_meta_tags
  = favicon_link_tag('favicon_64x64.ico')
  = javascript_include_tag "//ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.min.js"
  = javascript_include_tag "//ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular-resource.min.js"
  meta[name="viewport" content="width=device-width, initial-scale=1.0"]

body.default

  = render("layouts/header")
  = yield
  = render("layouts/footer")

Solution

  • I've never used slim, I just looked at their docs

    Attributes

    You write attributes directly after the tag. For normal text attributes you must use double " or single quotes ' (Quoted attributes).

    a href="http://slim-lang.com" title='Slim Homepage' Goto the Slim homepage
    

    Since ng-app is just a tag attribute, you can do something like:

    body.default ng-app="myApp"