That would be the controller code for the partial. Let's say the app
has an admin screen to manage users. The corresponding partial is a
master/detail CRUD dialog/screen. The HTML snippet would contain the
markup and the script tag to load the controller dealing with fetching
the data etc. The same is only needed for the partial area, nowhere
else.
In the augmented example:
<script>
function SettingsCntl2(){
this.cancel();
}
SettingsCntl2.prototype = {
cancel: function(){
this.form = angular.copy(this.person);
},
save: function(){
angular.copy(this.form, this.person);
window.location.hash = "#";
}
};
</script>
<div ng:controller="SettingsCntl2">
<label>Name:</label>
...
On Jun 23, 7:46 am, Igor Minar <
iimi...@gmail.com> wrote:
> I see. That's an interesting use case and I was kind of suspecting that you
> were trying to do that, but I wasn't sure.
>
> my question is: what's the code that you load this way? Don't you need to
> have the js code for the view before the view is rendered?
>
> /i
>
>
>
>
>
>
>
> On Wed, Jun 22, 2011 at 3:33 PM, Thomas <
thomas.we...@googlemail.com> wrote:
> > Hi Igor,
>
> > Thanks for the reply, with jquery included my test app works as
> > anticipated!
>
> > Why load JavaScript like this? I'm looking for a way to keep the
> > application modular. Right now it is a small test, but in a large
> > application I would like to be able to separate along functional
> > boundaries. Consider the case of "partials" that share nothing but a
> > common application frame and the browser window object. I would like
> > to keep the corresponding source artifacts separate and only load them
> > when needed. So instead of pulling all controller JavaScript when the
> > document is instantiated, pull it as the user actually visits the
> > "partial", by referencing it in the corresponding HTML snippet.
>
> > Is there any other/better way to accomplish the same with angular?
>
> > Cheers,
> > Thomas
>