0

I am developing single page application using partial views and angularJS. I am having a scenario where I have to open same partial view multiple times with different data.

I tried to make controller name dynamic by adding app.directive and changing controller name both in js and html and then calls Angular-Complies method, but the issue is that it changes it for all previous tabs opened. Then I tried to make multiple js files and changing controller name in partial view with Jquery but still does not helps. Here is my code.

HTML:

<div ng-app="myApp">
   <!-- this is in view1.html -->
    <div ng-controller="DashboardDesignerController">
            <div ng-repeat="widget in workspace.widgets">stuff here
            </div>
   </div>
    <!-- this is in view1.html -->
    <div ng-controller="DashboardDesignerController">
            <div ng-repeat="widget in workspace.widgets">stuff here
            </div>
   </div>

//Angular controller is in separate JS file.

   app.controller("DashboardDesignerController" , function ($scope, $http, 
   $rootScope, $compile, $injector, $timeout) {
   }

I expect to behave every tab separately according to its data but currently when I go to first opened tab, it's scope changed with the last opened tab. Is there built in way of angularJS to doing it, Or some good approach will also appreciated.

2
  • Is the number of times you have to replicate your controller fixed, or can it by dynamic? Commented Feb 20, 2019 at 12:27
  • Not fixed, Its dynamic. Commented Feb 21, 2019 at 8:04

1 Answer 1

0

Actually the issue was, I was calling chart drill down method in core JavaScript which was replacing $scope with last opened. Resolved the issue by getting scope with JQuery

var scope= angular.element($('.k-state-active').find('.tempDiv')[0]).scope();

and called angular function with this scope variable.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.