jaruesink
jaruesink

Reputation: 1203

Angular on Meteor with CoffeeScript/Jade

I feel like I'm so close, but I get hung up on why this setup isn't working for me. https://github.com/jaruesink/first_meteor

Thanks for anyone who can help out with this, I'm just trying to learn and have fun with a new project.

scripts/_main.coffee

@App = angular.module('App', [
'angular-meteor'
'ngMaterial'
'ui.router'
])

@App.config [
    '$interpolateProvider'
    ($interpolateProvider) ->
        $interpolateProvider
            .startSymbol '[['
            .endSymbol   ']]'
]

scripts/router.coffee

@App.config [
    '$stateProvider', '$urlRouterProvider', '$locationProvider'
    ($stateProvider, $urlRouterProvider, $locationProvider) ->
        $locationProvider.html5Mode true
        $urlRouterProvider.otherwise '/home'
        $stateProvider.state('home'
            url: '/home'
            templateUrl: UiRouter.template 'home'
        )
]

index.jade

head
    title App
    base(href="/")
body(ng-app="App")
    div.container
        h1 If 2 + 5 = [[2+5]], then I'm working :-)
        p but why isn't the router below showing up?
        div(ui-view)

views/home/home.jade

template(name='home')
section#home
    div.container
        h1 hello world, 1 + 2 = [[1+2]]

but here is what happens (the highlighted ui-view repeats the header code with all of the scripts again too)

I get duplicate code where one works and the other doesn't

enter image description here

Upvotes: 1

Views: 343

Answers (1)

GUISSOUMA Issam
GUISSOUMA Issam

Reputation: 2582

In your file router.coffee, On the templateUrl attribute you just need to mention the name of template like below:

@App.config [
    '$stateProvider', '$urlRouterProvider', '$locationProvider'
    ($stateProvider, $urlRouterProvider, $locationProvider) ->
        $locationProvider.html5Mode true
        $urlRouterProvider.otherwise '/home'
        $stateProvider.state('home'
            url: '/home'
            templateUrl: 'home'
        )
]

Your application will work fine

Test of App

Upvotes: 1

Related Questions