0

I have a module designed with this view and controller . Now , I want to move this same View and Controller to another Module ... basically want to include the functionality into another module.

Now, I have created a new controller for this module and passed the 'previously used controller's name' in it

$scope.includeViews =
        [ 
          {'title':'Info', url: appdata.baseurl +'/app/partials/profile/info.html', controller : 'infoData'}
        ];

Also ,, this is how i am including the 'previously used view' ..actually i am dealing wth tabs here to load the view ...its as follows

<tab heading="{{includeViews[0].title}}">
                <div class="slide-animate-container">
                    <div class="slide-animate" ng-include="includeViews[0].url" ng-controller="infoData"></div>
                </div>
            </tab>

The scope is not getting copied when using ng-include ..so I am not able to fetch the Data

Please tell me how do i deal with this , I dont want to code new as i am copying the same functionality of one module into another .. Thanks !

4

2 回答 2

0

Angular中有一个叫做Directive的东西,它正是为了创建可重用的组件。这是您正在寻找的解决方案,指令可以在不同的模块中重用。检查角度指令文档

https://docs.angularjs.org/guide/directive

于 2014-07-29T14:24:51.067 回答
0

我自己找到了解决方案......我只是在我的视图的 ng-model 值前面加上了 $parent 前缀,我必须包含......

<div class="control-group">
            <label  class="control-label" for="fname"><b>Name:</b></label>
            <div  class="controls">
                <input name="fname" type="text" ng-model="$parent.info.data"/><br/>

            </div>
        </div>

也适用于表格......做同样的事情

参考链接是 https://github.com/angular/angular.js/wiki/Understanding-Scopes#ng-include

于 2014-07-31T15:21:54.423 回答