Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何从 transclude 中的另一个控制器更改指令变量(在指令控制器中)?
如果要跨控制器更改变量,则必须使用 $rootScope 而不是 $scope。例如:
abc 是你的变量。
像这样使用它:
$rootScope.abc = 1; (directive controller) // and change it's value in other controller $rootScope.abc = 2; (another controller)