data binding - AngularJS TemplateUrl doesn't bind to $scope -


i know question has been asked before, looked @ them all, , couldn't find anything. here have:

layout.html

<html ng-app="myapp">    ...    <div my-container></div>    ... </html> 

app.js

var app = angular.module('myapp', [] ); app.directive('mycontainer', function(){     return {         restrict: 'a',         replace: true,         templateurl: '/path/to/view.html',         link: function(scope) {             scope.param = 3;          }     } }); 

view.html

<div>    {{ param }} </div> 

on run, view.html loaded, still see {{ param }}. don't understand why! please advise.


here exact code. using laravel angularjs. hierarchy followed:

/app    /app       ... laravel back-end, including layout.blade.php    /bootstrap    /public        /app            /views                minicalendar.html            /controllers            /lib            ...            app.js        index.php  

app.js

var app = angular.module('mainapp', [] );     app.directive('minicalendar', function() {     return {         restrict: 'a',         replace: true,         templateurl: '/app/views/minicalendar.html',         link: function(scope) {             scope.title = 'march'; // example.     } } 

});

minicalendar.html

<block mini-calendar class="full-content block mini-calendar" name="mini-calendar">    <!-- code here -->    <span class="large-10 columns text-bold ti" ng-hide="hide" ng-click='headertoggle()'>{{ title }}</span>    <!-- code here --> </block> 

your path wrong ,i tested code , worked, here's live example: http://plnkr.co/edit/d5rgpaj1npixcqsrqcd1?p=preview


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -